Closed arteymix closed 8 years ago
Here's a preview for pretty prints:
For vertices:
dtype: gdouble, dsize: 8, shape: (6), mem: 48B
[1.000000
1.000000
1.000000
1.000000
1.000000
1.000000]
For matrix:
dtype: gdouble, dsize: 8, shape: (5, 6), mem: 240B
[[0.000000, [0.000000, [0.000000, [0.000000, [0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000] 0.000000] 0.000000] 0.000000] 0.000000]]
For embedded matrix (ndim > 2
)
dtype: gdouble, dsize: 8, shape: (4, 5, 6), mem: 960B
[
[[0.000000, [0.000000, [0.000000, [0.000000, [0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1.000000] 0.000000] 0.000000] 0.000000] 0.000000]]
[[0.000000, [0.000000, [0.000000, [0.000000, [0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000] 0.000000] 0.000000] 0.000000] 0.000000]]
[[0.000000, [0.000000, [0.000000, [0.000000, [0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000] 0.000000] 0.000000] 0.000000] 0.000000]]
[[0.000000, [0.000000, [0.000000, [0.000000, [0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000] 0.000000] 0.000000] 0.000000] 0.000000]]]
It would be nice for embedded matrix to have a single line of [[[[
and use proper indentation.
There's also a missing comma at the end of each matrix vertex.
need a rebase or maybe I shall revert some changes in src/array.vala?
@rainwoodman I'll deal with conflicts, I did [CCode (array_length = false)]
twice.
@rainwoodman I would really like that we do not prefix everything with Array
, this library is basically revolving around that concept, so it get quite verbose to have StringArrayFormatter
and the like.
Yes it gets quite verbose!
I am guessing we will eventually wrap all array stuff in a subnamespace anyways, like Vast.Array, So let's remove Array prefix from class names.
FYI: Some reading about matrix objects and nd array objects: https://docs.scipy.org/doc/numpy/reference/arrays.classes.html#matrix-objects
Good I'll read some of it. I managed to understand strides since our last call and it's quite nice.
I'll probably start drafting some prototype about the computing graph this week.
If you can, commit and merge often -- at this stage we don't really need to guarentee everything in the repo is runs correctly. (Just note broken parts with FIXME in the source).
I already have something about introspection of functions here: https://github.com/rainwoodman/vast/tree/wip/arteymix/function-introspection.
It uses https://valadoc.org/gobject-introspection-1.0/GI.CallableInfo.html and the good thing is that it allow you to both introspect and call the function.
The following is what I try to accomplish:
var sin = new Function (GI.Repository.find_by_name ("Vast", "sin"));
sin.apply (in_array, ref out_array);
The Function
wraps a CallableInfo
and should extract all the information as well as the gradiant expression.
In the future, we'll want to have some description language (e.g. YAML) to get the graph.
This is what I will try to accomplish:
var sin = new Operation(....);
var cos = new Operation(....);
var x = new Variable();
var r = new Variable();
sin.connect({x, r});
cos.connect({r, y})
var x0 = Array(...);
x.initialize(x0);
var y = y.evaluate();
Or maybe something similar. There needs to a stage where Array is bound to variables and Operation is bound to Function. The binding betwen operation and function could happen during
var sin = new Function (GI.Repository.find_by_name ("Vast", "sin"));
If Function
class implementes the Operation interface too.
Alternatively
var func = cos.nest(sin);
var x0 = Array(...);
var y = func.evaluate(x0);
But we need to save the temporaries during the evaluation.
Shall we merge this as is? String can be dealt with later.
Not yet, I'll make the tests work first (which is just a couple of changes) and we can finish all the set_value
get_value` after.
I'm merging the changes. We'll finish get_value
and set_value
later.
There's some work to do to fully implement pointer to
GValue
and its reciprocate. This endpoint is just a convenience because it's generally more efficient to work directly with pointers.I also provide a pretty-print implementation based on
GLib.Value.strdup_contents
. It's nice as it considers matrix and vertices and print them vertically.