1 
2 #include <igraph.h>
3 
main()4 int main() {
5     igraph_matrix_t m;
6     igraph_vector_t x, y, z;
7     igraph_real_t xz, xx;
8 
9     igraph_vector_init_real(&x, 3, 1.0, 2.0, 3.0);
10     igraph_vector_init_real(&y, 4, 4.0, 5.0, 6.0, 7.0);
11     igraph_vector_init_real(&z, 3, -1.0, 0.0, 0.5);
12 
13     igraph_matrix_init(&m, 4, 3);
14     MATRIX(m, 0, 0) = 1;
15     MATRIX(m, 0, 1) = 2;
16     MATRIX(m, 0, 2) = 3;
17     MATRIX(m, 1, 0) = 2;
18     MATRIX(m, 1, 1) = 3;
19     MATRIX(m, 1, 2) = 4;
20     MATRIX(m, 2, 0) = 3;
21     MATRIX(m, 2, 1) = 4;
22     MATRIX(m, 2, 2) = 5;
23     MATRIX(m, 3, 0) = 4;
24     MATRIX(m, 3, 1) = 5;
25     MATRIX(m, 3, 2) = 6;
26 
27     /* Compute 2 m.x + 3 y and store it in y. */
28     igraph_blas_dgemv(/* transpose= */ 0, /* alpha= */ 2, &m, &x, /* beta= */ 3, &y);
29     igraph_vector_print(&y);
30 
31     /* Compute the squared norm of x, as well as the dor product of x and z. */
32     igraph_blas_ddot(&x, &x, &xx);
33     igraph_blas_ddot(&x, &z, &xz);
34     printf("x.x = %g, x.z = %g\n", xx, xz);
35 
36     igraph_matrix_destroy(&m);
37     igraph_vector_destroy(&z);
38     igraph_vector_destroy(&y);
39     igraph_vector_destroy(&x);
40 
41     return 0;
42 }
43