1 #include "UnaryF64.h"
2 #include "Error.h"
3 
4 /* Upper bound of maximum matrix dimension used by Python */
5 #define MAXMATRIXDIM 40
6 
7 /*
8 
9 Offset in input test pattern for matrix of dimension d * d.
10 Must be coherent with Python script Matrix.py
11 
12 */
cholesky_offset(int d)13 static int cholesky_offset(int d)
14 {
15   int offset=14;
16   switch (d)
17   {
18    case 4:
19      offset = 14;
20    break;
21    case 8:
22      offset = 79;
23    break;
24    case 9:
25      offset = 143;
26    break;
27    case 15:
28      offset = 224;
29    break;
30    case 16:
31      offset = 449;
32    break;
33    default:
34     offset = 14;
35    break;
36   }
37 
38   return(offset);
39 }
40 
test_mat_inverse_f64()41     void UnaryF64::test_mat_inverse_f64()
42     {
43        arm_mat_inverse_f64(&this->in1,&this->out);
44     }
45 
test_mat_cholesky_dpo_f64()46     void UnaryF64::test_mat_cholesky_dpo_f64()
47     {
48         arm_mat_cholesky_f64(&this->in1,&this->out);
49     }
50 
test_solve_upper_triangular_f64()51     void UnaryF64::test_solve_upper_triangular_f64()
52     {
53         arm_mat_solve_upper_triangular_f64(&this->in1,&this->in2,&this->out);
54     }
55 
test_solve_lower_triangular_f64()56     void UnaryF64::test_solve_lower_triangular_f64()
57     {
58         arm_mat_solve_lower_triangular_f64(&this->in1,&this->in2,&this->out);
59     }
60 
61 
setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)62     void UnaryF64::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
63     {
64 
65 
66        std::vector<Testing::param_t>::iterator it = params.begin();
67        this->nbr = *it++;
68        this->nbc = *it;
69 
70        switch(id)
71        {
72           case TEST_MAT_INVERSE_F64_1:
73 
74             input1.reload(UnaryF64::INPUTA_F64_ID,mgr,this->nbr*this->nbc);
75 
76 
77             output.create(this->nbr*this->nbc,UnaryF64::OUT_F64_ID,mgr);
78 
79             this->in1.numRows = this->nbr;
80             this->in1.numCols = this->nbc;
81             this->in1.pData = input1.ptr();
82 
83             this->out.numRows = this->nbr;
84             this->out.numCols = this->nbc;
85             this->out.pData = output.ptr();
86           break;
87 
88           case TEST_MAT_CHOLESKY_DPO_F64_2:
89           {
90             int offset=14;
91             float64_t *p;
92             float64_t *aPtr;
93             input1.reload(UnaryF64::INPUTSCHOLESKY1_DPO_F64_ID,mgr);
94             output.create(this->nbc * this->nbr,UnaryF64::OUT_F64_ID,mgr);
95 
96             a.create(this->nbr*this->nbc,UnaryF64::TMPA_F64_ID,mgr);
97 
98             /* Offsets must be coherent with the sizes used in python script
99                 Matrix.py for pattern generation */
100             offset=cholesky_offset(this->nbr);
101 
102              p = input1.ptr();
103              aPtr = a.ptr();
104 
105 
106 
107              memcpy(aPtr,p + offset,sizeof(float64_t)*this->nbr*this->nbr);
108 
109              this->out.numRows = this->nbr;
110              this->out.numCols = this->nbc;
111              this->out.pData = output.ptr();
112 
113              this->in1.numRows = this->nbr;
114              this->in1.numCols = this->nbc;
115              this->in1.pData = aPtr;
116 
117 
118 
119           }
120           break;
121 
122           case TEST_SOLVE_UPPER_TRIANGULAR_F64_3:
123           {
124              int offset=14;
125              float64_t *p;
126              float64_t *aPtr;
127              float64_t *bPtr;
128 
129              input1.reload(UnaryF64::INPUT_UT_DPO_F64_ID,mgr);
130              input2.reload(UnaryF64::INPUT_RNDA_DPO_F64_ID,mgr);
131              output.create(this->nbc * this->nbr,UnaryF64::OUT_F64_ID,mgr);
132 
133              a.create(this->nbr*this->nbc,UnaryF64::TMPA_F64_ID,mgr);
134              b.create(this->nbr*this->nbc,UnaryF64::TMPB_F64_ID,mgr);
135 
136              /* Offsets must be coherent with the sizes used in python script
137                 Matrix.py for pattern generation */
138              offset=cholesky_offset(this->nbr);
139 
140              p = input1.ptr();
141              aPtr = a.ptr();
142              memcpy(aPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
143 
144              p = input2.ptr();
145              bPtr = b.ptr();
146              memcpy(bPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
147 
148              this->out.numRows = this->nbr;
149              this->out.numCols = this->nbc;
150              this->out.pData = output.ptr();
151 
152              this->in1.numRows = this->nbr;
153              this->in1.numCols = this->nbc;
154              this->in1.pData = aPtr;
155 
156              this->in2.numRows = this->nbr;
157              this->in2.numCols = this->nbc;
158              this->in2.pData = bPtr;
159           }
160           break;
161 
162           case TEST_SOLVE_LOWER_TRIANGULAR_F64_4:
163           {
164              int offset=14;
165              float64_t *p;
166              float64_t *aPtr;
167              float64_t *bPtr;
168 
169              input1.reload(UnaryF64::INPUT_LT_DPO_F64_ID,mgr);
170              input2.reload(UnaryF64::INPUT_RNDA_DPO_F64_ID,mgr);
171              output.create(this->nbc * this->nbr,UnaryF64::OUT_F64_ID,mgr);
172 
173              a.create(this->nbr*this->nbc,UnaryF64::TMPA_F64_ID,mgr);
174              b.create(this->nbr*this->nbc,UnaryF64::TMPB_F64_ID,mgr);
175 
176              /* Offsets must be coherent with the sizes used in python script
177                 Matrix.py for pattern generation */
178              offset=cholesky_offset(this->nbr);
179 
180              p = input1.ptr();
181              aPtr = a.ptr();
182              memcpy(aPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
183 
184              p = input2.ptr();
185              bPtr = b.ptr();
186              memcpy(bPtr,&p[offset],sizeof(float64_t)*this->nbr*this->nbr);
187 
188              this->out.numRows = this->nbr;
189              this->out.numCols = this->nbc;
190              this->out.pData = output.ptr();
191 
192              this->in1.numRows = this->nbr;
193              this->in1.numCols = this->nbc;
194              this->in1.pData = aPtr;
195 
196              this->in2.numRows = this->nbr;
197              this->in2.numCols = this->nbc;
198              this->in2.pData = bPtr;
199           }
200           break;
201         }
202     }
203 
tearDown(Testing::testID_t id,Client::PatternMgr * mgr)204     void UnaryF64::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
205     {
206     }
207