julia_array
is a helper function to create Julia arrays including vectors, matrices and etc.
And it can be used in functions to facilitate automatic differentiation.
julia_array(data, n1, n2, ...)
data | the data to create the array. |
---|---|
n1, n2, ... | the dimensions. |
If n1 is missing, then all the dimensions will be ignored, and the result will be a Julia array coresponding to the data argument. If n1, n2, ... are given, they will determine the shape of the result, and data will be used for the content.
## setup is quite time consuming julia_array(0, 3) ## will return a Julia vector with length 3 and filled with 0#> Error in .julia$simple_call_(func, ...): 不适用于非函数julia_array(0, 3, 4) ## will return a Julia matrix of 3x4 and filled with 0#> Error in .julia$simple_call_(func, ...): 不适用于非函数julia_array(matrix(1, 2, 2)) ## dimension is not given, will return a Julia matrix#> Error in .julia$simple_call_(func, ...): 不适用于非函数julia_array(matrix(1, 2, 2), 4) ## dimension is given, will return a Julia vector#> Error in .julia$simple_call_(func, ...): 不适用于非函数