@@ -14,24 +14,25 @@ const char *test_linear_op()
1414{
1515 /* create CSR matrix
1616 A = [0 0 2 3 0 0]
17- [1 2 1 0 2 0]
18- [1 2 3 4 5 6 ] */
19- double Ax [12 ] = {2.0 , 3.0 , 1.0 , 2.0 , 1.0 , 2.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6 .0 };
20- int Ai [12 ] = {2 , 3 , 0 , 1 , 2 , 4 , 0 , 1 , 2 , 3 , 4 , 5 };
21- int Ap [4 ] = {0 , 2 , 6 , 12 };
22- CSR_Matrix * A = new_csr_matrix (3 , 6 , 12 );
23- memcpy (A -> x , Ax , 12 * sizeof (double ));
24- memcpy (A -> i , Ai , 12 * sizeof (int ));
17+ [0 0 1 0 2 0]
18+ [0 0 3 4 5 0 ] */
19+ double Ax [7 ] = {2.0 , 3.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 };
20+ int Ai [7 ] = {2 , 3 , 2 , 4 , 2 , 3 , 4 };
21+ int Ap [4 ] = {0 , 2 , 4 , 7 };
22+ CSR_Matrix * A = new_csr_matrix (3 , 6 , 7 );
23+ memcpy (A -> x , Ax , 7 * sizeof (double ));
24+ memcpy (A -> i , Ai , 7 * sizeof (int ));
2525 memcpy (A -> p , Ap , 4 * sizeof (int ));
2626
2727 expr * var = new_variable (3 , 2 , 6 );
2828 expr * linear_node = new_linear (var , A );
29- double x [6 ] = {1 , 1 , 1 , 2 , 3 , 1 };
29+ double x [6 ] = {0 , 0 , 1 , 2 , 3 , 0 };
3030 linear_node -> forward (linear_node , x );
3131
3232 double expected [3 ] = {8 , 7 , 26 };
3333 mu_assert ("fail" , cmp_double_array (linear_node -> value , expected , 3 ));
3434 free_expr (linear_node );
35+ free_expr (var );
3536 free_csr_matrix (A );
3637 return 0 ;
3738}
0 commit comments