Skip to content

[Easy] Sample Code

Marcel Pawelczyk edited this page Dec 6, 2021 · 6 revisions

Generating a 2D Vector

In this sample code, we will construct a 2D vector using hardcoded values.

using BAVCL;

GPU gpu = new GPU();

// Create a predefined 2D vector with 4 columns
Vector vector2D = new Vector(gpu, new float[12] {1f,2f,3f,4f,5f,6f,7f,8f,9f,10f,11f,12f}, 4);

vector2D.Print();

Simple 2D Vector

Lore:

BAVCL projects 2D vectors into 1D space to maximise performance. The column parameter provided is used to define the number of columns a vector has. Combining the column parameter with the array length, BAVCL can therefore imply the row count to create a 2D vector, using the formula; rowCount = length / columns. By default, the Algebraic Vector class sets the column value to 1, which indicates that the vector is 1D. Any column values above 1 indicate the vector is 2D of shape defined by its length and column count.

Clone this wiki locally