Length of the array.
Number of dimensions of the array.
Get the raw pointer of the array.
Size (equivalent to shape in numpy's terms) of the array.
Iterate over the array elements.
Create a copy of this array.
The copy is independent - changes to the copy do not affect the original.
A new JuliaArray with the same data.
Fill the array with the given value.
Value to be filled.
Get data at the given linear index (column-major order).
For multi-dimensional arrays, consider using getAt(...indices) for
more intuitive access.
The linear index (starting from 0) to be fetched.
Julia data at the given index, wrapped in a JuliaValue object.
Get data at the given multi-dimensional indices.
Indices are 0-based and follow Julia's column-major convention.
For a 2D matrix, use getAt(row, col).
The indices for each dimension (all 0-based).
Julia data at the given position, wrapped in a JuliaValue object.
Map the given function to the array and get a new array.
Function to be mapped.
Pop the last element of the array and return it.
Reshape the array with the given shape and get a new array.
Note that the new array shares the underlying memory with the original array.
So if you have reshaped an array, you cannot perform pop() or push() operations
on it since this will affect the arrays that share data with the current array.
Reverse the array in place.
Set data at the given linear index (column-major order).
For multi-dimensional arrays, consider using setAt(...indices, value) for
more intuitive access.
The linear index (starting from 0).
Data to be set at the given index.
Set data at the given multi-dimensional indices.
Indices are 0-based and follow Julia's column-major convention.
For a 2D matrix, use setAt(row, col, value).
The indices for each dimension followed by the value to set. For an N-dimensional array, pass N indices then the value.
Create a contiguous view (slice) of elements from start to stop (0-based, inclusive).
This is a convenience method for 1D array views.
Start index (0-based, inclusive).
Stop index (0-based, inclusive).
A new JuliaSubArray.
Create a view (SubArray) of this array with specified indices.
Views share memory with the parent array - changes to the view are reflected in the parent and vice versa.
Index specifications. Can be:
number: Single index (0-based, converted to 1-based for Julia)":": All elements in that dimension (equivalent to Julia's :)[start, stop]: Range (0-based, inclusive)[start, step, stop]: Stepped range (0-based)A new JuliaSubArray.
const arr = JuliaArray.from(new Float64Array([1, 2, 3, 4, 5]));
// View elements 1..3 (0-based indices)
const sub1 = arr.view([1, 3]);
// View every other element
const sub2 = arr.view([0, 2, 4]); // step=2
// For multi-dimensional arrays
const matrix = Julia.eval("reshape(Float64.(1:12), 3, 4)") as JuliaArray;
const col = matrix.view(":", 0); // All rows, first column
StaticfromCreate a JuliaArray from a BunArray (TypedArray | BigInt64Array | BigUint64Array).
StaticfromStaticinitCreate a JuliaArray with given element type and dimensions.
Element type of the array.
Dimensions of the array. For 1D array, pass a single number. For multi-dimensional arrays, pass multiple numbers.
// 1D array with 100 elements
const arr1d = JuliaArray.init(Julia.Float64, 100);
// 2D array (10x20 matrix)
const arr2d = JuliaArray.init(Julia.Float64, 10, 20);
// 3D array (10x20x30)
const arr3d = JuliaArray.init(Julia.Float64, 10, 20, 30);
// N-dimensional array
const arrNd = JuliaArray.init(Julia.Float64, 2, 3, 4, 5);
Wrapper for Julia
Array.Column-Major Order
Julia uses column-major order (like Fortran), meaning elements are stored column-by-column in memory. This is different from C/JavaScript which use row-major order.
For a 2D array (matrix), elements are stored as:
Example: For a 2x3 matrix:
When using
get(linearIndex)orset(linearIndex, value), the linear index follows column-major order. For multi-dimensional access, usegetAt(...indices)andsetAt(...indices, value)which handle the index conversion automatically.Example