MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / boost_matrix_conversions

Function boost_matrix_conversions

examples_boost/extensibility.cpp:208–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void boost_matrix_conversions()
209{
210 matrix<double> A(2, 2);
211 A(0, 0) = 1.1;
212 A(0, 1) = 2.1;
213 A(1, 0) = 3.1;
214 A(1, 1) = 4.1;
215
216 json a = A;
217
218 assert(a.is<matrix<double>>());
219 assert(!a.is<matrix<int>>());
220
221 assert(a[0][0].as<double>()==A(0,0));
222 assert(a[0][1].as<double>()==A(0,1));
223 assert(a[1][0].as<double>()==A(1,0));
224 assert(a[1][1].as<double>()==A(1,1));
225
226 matrix<double> B = a.as<matrix<double>>();
227
228 assert(B.size1() ==a.size());
229 assert(B.size2() ==a[0].size());
230
231 assert(a[0][0].as<double>()==B(0,0));
232 assert(a[0][1].as<double>()==B(0,1));
233 assert(a[1][0].as<double>()==B(1,0));
234 assert(a[1][1].as<double>()==B(1,1));
235}
236
237
238void boost_multiprecison_conversions()

Callers 1

extensibility_examplesFunction · 0.85

Calls 2

AClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected