$ mkdir example1 $ cd example1
#include <stdio.h> #include <oski/oski.h> /* Declare a 3x3 lower triangular matrix, / 1 0 0 \ A = | -2 1 0 | , \ .5 0 1 / in CSR format with 0-based indices and an implicitly stored unit diagonal. */ #define DIM 3 #define NUM_STORED_NZ 2 int Aptr[ DIM+1 ] = { 0, 0, 1, 2 }; int Aind[ NUM_STORED_NZ ] = { 0, 0 }; double Aval[ NUM_STORED_NZ ] = { -2, 0.5 }; /* Some dummy vectors, for multiplication later */ double x[ DIM ] = { .25, .45, .65 }; double y[ DIM ] = { 1, 1, 1 }; int main( int argc, char** argv ) { oski_matrix_t A_tunable; oski_vecview_t x_view, y_view; oski_Init(); A_tunable = oski_CreateMatCSR( Aptr, Aind, Aval, DIM, DIM, SHARE_INPUTMAT, /* properties: */ 3, INDEX_ZERO_BASED, MAT_TRI_LOWER, MAT_UNIT_DIAG_IMPLICIT ); x_view = oski_CreateVecView( x, DIM, STRIDE_UNIT ); y_view = oski_CreateVecView( y, DIM, STRIDE_UNIT ); /* Perform y <-- y - A*x */ oski_MatMult( A_tunable, OP_NORMAL, -1, x_view, 1, y_view ); /* Clean-up */ oski_DestroyMat( A_tunable ); oski_DestroyVecView( x_view ); oski_DestroyVecView( y_view ); /* Print result */ printf( "Answer: y = [ %f ; %f ; %f ]\n", y[0], y[1], y[2] ); oski_Close(); return 0; }
$ icc -I${OSKIDIR}/include -O3 -o example1 example1.c \ -L${OSKIDIR}/lib/oski -Wl,-rpath ${OSKIDIR}/lib/oski \ -loski_Tid -loski -loski_core_Tid -loski_core -loskilt
$ ./example1 Answer: y = [ 0.75 ; 1.05 ; 0.225 ]
$ env OSKI_DEBUG_LEVEL=10 ./example1