|
1 | | -// SPDX-License-Identifier: Apache-2.0 |
2 | | - |
3 | 1 | #include <stdio.h> |
4 | 2 |
|
5 | 3 | #include "atoms/affine.h" |
6 | 4 | #include "expr.h" |
7 | 5 | #include "minunit.h" |
8 | 6 | #include "test_helpers.h" |
9 | 7 |
|
10 | | -const char *test_upper_tri_forward(void) |
11 | | -{ |
12 | | - /* 3x3 matrix variable (column-major): [1,2,3,4,5,6,7,8,9] |
13 | | - * Matrix: 1 4 7 |
14 | | - * 2 5 8 |
15 | | - * 3 6 9 |
16 | | - * Upper tri in row-major order (matching CVXPY): |
17 | | - * Row 0: (0,1)=4, (0,2)=7 |
18 | | - * Row 1: (1,2)=8 |
19 | | - * Flat indices: 3, 6, 7 */ |
20 | | - double u[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; |
21 | | - expr *var = new_variable(3, 3, 0, 9); |
22 | | - expr *ut = new_upper_tri(var); |
23 | | - |
24 | | - mu_assert("upper_tri d1", ut->d1 == 3); |
25 | | - mu_assert("upper_tri d2", ut->d2 == 1); |
26 | | - |
27 | | - ut->forward(ut, u); |
28 | | - |
29 | | - double expected[3] = {4.0, 7.0, 8.0}; |
30 | | - mu_assert("upper_tri forward", cmp_double_array(ut->value, expected, 3)); |
31 | | - |
32 | | - free_expr(ut); |
33 | | - return 0; |
34 | | -} |
35 | | - |
36 | 8 | const char *test_upper_tri_forward_4x4(void) |
37 | 9 | { |
38 | 10 | /* 4x4 matrix variable (column-major): [1..16] |
|
0 commit comments