main.cpp 1.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "blc_core.h"

int main(int argc, char **argv){
    blc_array vector, matrix;
    int i, width, height;
    
    //We define the properties of an array of type char (INT8) with undef format (i.e. the user use it as he wants), of one dimension (vector) of 32 values.
    vector.def_array('INT8', 'NDEF', 1, 32);
    
    //The properties .dims have to be freed.
    //Be careful the .data memory is not allocated ! This is usefull if you want to associate the data to your own memory.
    //We display the properties
    vector.fprint_properties(stderr);
    fprintf(stderr, "\n");
    //We allocate the memory
    vector.allocate();
    
    // We set all the bytes to 3
    for(i=0; i!=vector.size; i++) vector.chars[i]=3;
    
    //We define a matrix of 3x5
    //The matrix is not allocated
    matrix.def_array('FL32', 'NDEF', 2, 3, 5);
    matrix.allocate();
    //We display  the dim sizes
    matrix.fprint_dims(stderr);
    fprintf(stderr, "\n");
    
    //We acquire the sizes of the dims
    width=matrix.dims[0].length;
    height=matrix.dims[1].length;
    fprintf(stderr, "width:%d, height:%d\n", width, height);
    
    //We set the first column of the matrix to 6.3
    for(i=0; i!=height; i++) matrix.floats[i*width]=6.3;

    /*Free the memory (.dims and .data)*/
    vector.destroy();
    matrix.destroy();
    
    return 0;
}