• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stillwater-sc / universal / 21373593817

26 Jan 2026 08:52PM UTC coverage: 84.006%. First build
21373593817

Pull #499

github

Ravenwater
Add comprehensive BLAS regression tests for coverage

Convert generators.cpp and matrix_ops.cpp from demos to proper
regression tests with assertions:

generators.cpp:
- Add VerifyIdentityGenerator, VerifyRowOrderIndex, VerifyColumnOrderIndex
- Add VerifyLaplace2D, VerifyMinij, VerifyMagicSquare
- Add VerifyUniformRandom, VerifyGaussianRandom
- Add VerifyHilbert (scaled and unscaled), VerifyTridiag
- Test with double, float, posit<32,2>, posit<16,1>

matrix_ops.cpp:
- Add VerifyTranspose, VerifyMatrixVectorProduct, VerifyMatrixMatrixProduct
- Add VerifyFusedMatrixOps for posit fused operations
- Add VerifyOperators (eye, diag, tril, triu)
- Add VerifyNorm (1-norm, 2-norm, inf-norm)
- Add VerifyMatnorm (matrix 1-norm and inf-norm)
- Add VerifyVmath (sqrt, square, power, sin, cos, tan)
- Test with float, double, posit<32,2>, bfloat16

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request #499: V3.93: UBSan fixes, image demo, and coverage workflow

588 of 852 new or added lines in 9 files covered. (69.01%)

33478 of 39852 relevant lines covered (84.01%)

6562329.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.13
/linalg/data/test_matrices.cpp
1
// test_matrices.cpp: convert test matrix include files to data files
2
//
3
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
4
// SPDX-License-Identifier: MIT
5
//
6
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
7
#include <universal/utility/directives.hpp>
8
#include <cmath>
9
#include <iostream>
10
#include <iomanip>
11
#include <fstream>
12

13
// Serialization - test_matrix.hpp reads matrices from .dat files
14
#include <blas/serialization/datafile.hpp>
15
#include <blas/serialization/test_matrix.hpp>
16

17
#include <universal/verification/test_suite.hpp>
18
#include <blas/matrices/testsuite.hpp>
19

20
namespace sw { namespace blas {
21
        using namespace sw::numeric::containers;
22

23
        static void WriteMatrixDataFile(const std::string& filename, const matrix<double>& A) {
×
24
                std::ofstream fo;
×
25
                fo.open(filename);
×
26
                fo << A;
×
27
                fo.close();
×
28
        }
×
29

30
        static void GenerateMatrixDataFiles(const std::vector<std::string>& testMatrixNames) {
×
31
                for (auto matrixName : testMatrixNames) {
×
32
                        WriteMatrixDataFile(matrixName + std::string(".dat"), getTestMatrix(matrixName));
×
33
                }
×
34
        }
×
35

36
        ////////////////////////////////////////////////////////////////////////
37
        // Test global getTestMatrix() from testsuite.hpp
38
        int VerifyGlobalGetTestMatrix(bool reportTestCases) {
1✔
39
                int nrOfFailedTests = 0;
1✔
40

41
                // Test all available matrices from testsuite.hpp
42
                std::vector<std::pair<std::string, std::pair<size_t, size_t>>> expectedDimensions = {
NEW
43
                        {"lambers_well", {2, 2}},
×
NEW
44
                        {"lambers_ill", {2, 2}},
×
NEW
45
                        {"h3", {3, 3}},
×
NEW
46
                        {"q3", {3, 3}},
×
NEW
47
                        {"int3", {3, 3}},
×
NEW
48
                        {"faires74x3", {3, 3}},
×
NEW
49
                        {"q4", {4, 4}},
×
NEW
50
                        {"lu4", {4, 4}},
×
NEW
51
                        {"s4", {4, 4}},
×
NEW
52
                        {"rand4", {4, 4}},
×
NEW
53
                        {"q5", {5, 5}},
×
NEW
54
                        {"b1_ss", {7, 7}},
×
NEW
55
                        {"cage3", {5, 5}},
×
NEW
56
                        {"pores_1", {30, 30}},
×
NEW
57
                        {"Stranke94", {10, 10}},
×
NEW
58
                        {"Trefethen_20", {20, 20}}
×
59
                };
19✔
60

61
                for (const auto& entry : expectedDimensions) {
17✔
62
                        const std::string& name = entry.first;
16✔
63
                        size_t expectedRows = entry.second.first;
16✔
64
                        size_t expectedCols = entry.second.second;
16✔
65

66
                        // Use global getTestMatrix (from testsuite.hpp)
67
                        matrix<double> M = ::getTestMatrix(name);
16✔
68

69
                        if (num_rows(M) != expectedRows || num_cols(M) != expectedCols) {
16✔
NEW
70
                                ++nrOfFailedTests;
×
NEW
71
                                if (reportTestCases) std::cerr << "FAIL: global getTestMatrix(" << name << ") = "
×
NEW
72
                                                               << num_rows(M) << "x" << num_cols(M)
×
NEW
73
                                                               << " (expected " << expectedRows << "x" << expectedCols << ")\n";
×
74
                        }
75
                }
16✔
76

77
                // Test unknown matrix returns default (lu4)
78
                matrix<double> unknown = ::getTestMatrix("unknown_matrix_xyz");
1✔
79
                if (num_rows(unknown) != 4 || num_cols(unknown) != 4) {
1✔
NEW
80
                        ++nrOfFailedTests;
×
NEW
81
                        if (reportTestCases) std::cerr << "FAIL: global getTestMatrix(unknown) should return lu4 (4x4)\n";
×
82
                }
83

84
                return nrOfFailedTests;
1✔
85
        }
5✔
86

87
        ////////////////////////////////////////////////////////////////////////
88
        // Test global kappa() from testsuite.hpp
89
        int VerifyGlobalKappa(bool reportTestCases) {
1✔
90
                int nrOfFailedTests = 0;
1✔
91

92
                // Test known condition numbers
93
                std::vector<std::pair<std::string, double>> expectedKappa = {
NEW
94
                        {"lambers_well", 10.0},
×
NEW
95
                        {"lambers_ill", 1.869050824603144e+08},
×
NEW
96
                        {"h3", 1.8478e+11},
×
NEW
97
                        {"q3", 1.2857e+06},
×
NEW
98
                        {"int3", 43.6115},
×
NEW
99
                        {"faires74x3", 15999},
×
NEW
100
                        {"q4", 2.35},
×
NEW
101
                        {"lu4", 11.6810},
×
NEW
102
                        {"s4", 4.19},
×
NEW
103
                        {"rand4", 27.81},
×
NEW
104
                        {"q5", 1.1e+04},
×
NEW
105
                        {"b1_ss", 1.973732e+02},
×
NEW
106
                        {"cage3", 1.884547e+01},
×
NEW
107
                        {"pores_1", 1.812616e+06},
×
NEW
108
                        {"Stranke94", 5.173300e+01},
×
NEW
109
                        {"Trefethen_20", 6.308860e+01}
×
110
                };
18✔
111

112
                for (const auto& entry : expectedKappa) {
17✔
113
                        const std::string& name = entry.first;
16✔
114
                        double expected = entry.second;
16✔
115

116
                        // Use global kappa (from testsuite.hpp)
117
                        double k = ::kappa(name);
16✔
118

119
                        // Use relative tolerance for comparison
120
                        double relError = std::abs(k - expected) / expected;
16✔
121
                        if (relError > 0.001) {
16✔
NEW
122
                                ++nrOfFailedTests;
×
NEW
123
                                if (reportTestCases) std::cerr << "FAIL: global kappa(" << name << ") = " << k
×
NEW
124
                                                               << " (expected " << expected << ")\n";
×
125
                        }
126
                }
127

128
                // Test unknown matrix returns default (lu4's kappa)
129
                double unknownK = ::kappa("unknown_matrix_xyz");
1✔
130
                if (std::abs(unknownK - 11.6810) > 0.01) {
1✔
NEW
131
                        ++nrOfFailedTests;
×
NEW
132
                        if (reportTestCases) std::cerr << "FAIL: global kappa(unknown) should return 11.6810\n";
×
133
                }
134

135
                return nrOfFailedTests;
1✔
136
        }
2✔
137

138
        ////////////////////////////////////////////////////////////////////////
139
        // Test matrix data values (not just dimensions)
140
        int VerifyMatrixValues(bool reportTestCases) {
1✔
141
                int nrOfFailedTests = 0;
1✔
142

143
                // Test lambers_well matrix values
144
                // lambers_well = [[1, 2], [3, 4]] or similar known values
145
                {
146
                        matrix<double> A = ::getTestMatrix("lambers_well");
1✔
147
                        if (num_rows(A) >= 2 && num_cols(A) >= 2) {
1✔
148
                                // Just verify the matrix has non-zero values
149
                                bool hasNonZero = false;
1✔
150
                                for (size_t i = 0; i < num_rows(A) && !hasNonZero; ++i) {
2✔
151
                                        for (size_t j = 0; j < num_cols(A) && !hasNonZero; ++j) {
2✔
152
                                                if (A[i][j] != 0.0) hasNonZero = true;
1✔
153
                                        }
154
                                }
155
                                if (!hasNonZero) {
1✔
NEW
156
                                        ++nrOfFailedTests;
×
NEW
157
                                        if (reportTestCases) std::cerr << "FAIL: lambers_well has all zero values\n";
×
158
                                }
159
                        }
160
                }
1✔
161

162
                // Test lu4 matrix values
163
                {
164
                        matrix<double> A = ::getTestMatrix("lu4");
1✔
165
                        if (num_rows(A) == 4 && num_cols(A) == 4) {
1✔
166
                                // Verify diagonal has non-zero values (for LU decomposition test matrices)
167
                                bool diagonalOK = true;
1✔
168
                                for (size_t i = 0; i < 4; ++i) {
5✔
169
                                        if (A[i][i] == 0.0) diagonalOK = false;
4✔
170
                                }
171
                                if (!diagonalOK) {
1✔
NEW
172
                                        ++nrOfFailedTests;
×
NEW
173
                                        if (reportTestCases) std::cerr << "FAIL: lu4 diagonal should be non-zero\n";
×
174
                                }
175
                        }
176
                }
1✔
177

178
                return nrOfFailedTests;
1✔
179
        }
180

181
        ////////////////////////////////////////////////////////////////////////
182
        // Test WriteMatrixDataFile function
NEW
183
        int VerifyWriteMatrixDataFile(bool reportTestCases) {
×
NEW
184
                int nrOfFailedTests = 0;
×
185

186
                // Create a small test matrix
NEW
187
                matrix<double> A(3, 3);
×
NEW
188
                A[0][0] = 1.0; A[0][1] = 2.0; A[0][2] = 3.0;
×
NEW
189
                A[1][0] = 4.0; A[1][1] = 5.0; A[1][2] = 6.0;
×
NEW
190
                A[2][0] = 7.0; A[2][1] = 8.0; A[2][2] = 9.0;
×
191

192
                // Write to temporary file
NEW
193
                std::string tempFile = "/tmp/test_matrix_write.dat";
×
NEW
194
                WriteMatrixDataFile(tempFile, A);
×
195

196
                // Read back and verify
NEW
197
                matrix<double> B;
×
NEW
198
                std::ifstream fi(tempFile);
×
NEW
199
                if (fi.good()) {
×
NEW
200
                        fi >> B;
×
NEW
201
                        fi.close();
×
202

NEW
203
                        if (num_rows(B) != 3 || num_cols(B) != 3) {
×
NEW
204
                                ++nrOfFailedTests;
×
NEW
205
                                if (reportTestCases) std::cerr << "FAIL: read back matrix has wrong dimensions\n";
×
206
                        } else {
207
                                // Verify values
NEW
208
                                for (size_t i = 0; i < 3; ++i) {
×
NEW
209
                                        for (size_t j = 0; j < 3; ++j) {
×
NEW
210
                                                if (std::abs(A[i][j] - B[i][j]) > 0.0001) {
×
NEW
211
                                                        ++nrOfFailedTests;
×
NEW
212
                                                        if (reportTestCases) std::cerr << "FAIL: matrix value mismatch at [" << i << "][" << j << "]\n";
×
213
                                                }
214
                                        }
215
                                }
216
                        }
217
                } else {
NEW
218
                        ++nrOfFailedTests;
×
NEW
219
                        if (reportTestCases) std::cerr << "FAIL: could not read back written matrix file\n";
×
220
                }
221

222
                // Clean up
NEW
223
                std::remove(tempFile.c_str());
×
224

NEW
225
                return nrOfFailedTests;
×
NEW
226
        }
×
227

228
        ////////////////////////////////////////////////////////////////////////
229
        // Compare file-loaded matrix with header-defined matrix
NEW
230
        int VerifyFileVsHeaderMatrices(bool reportTestCases) {
×
NEW
231
                int nrOfFailedTests = 0;
×
232

233
                // Compare matrices that are available in both formats
234
                std::vector<std::string> matricesToCompare = {
235
                        "lambers_well",
236
                        "lambers_ill",
237
                        "lu4",
238
                        "q4"
NEW
239
                };
×
240

NEW
241
                for (const auto& name : matricesToCompare) {
×
242
                        // Get from header (global function)
NEW
243
                        matrix<double> fromHeader = ::getTestMatrix(name);
×
244

245
                        // Get from file (sw::blas function)
NEW
246
                        matrix<double> fromFile = sw::blas::getTestMatrix(name);
×
247

NEW
248
                        if (num_rows(fromFile) == 0 || num_cols(fromFile) == 0) {
×
249
                                // File doesn't exist, skip comparison
NEW
250
                                continue;
×
251
                        }
252

NEW
253
                        if (num_rows(fromHeader) != num_rows(fromFile) || num_cols(fromHeader) != num_cols(fromFile)) {
×
NEW
254
                                ++nrOfFailedTests;
×
NEW
255
                                if (reportTestCases) std::cerr << "FAIL: " << name << " dimension mismatch between header and file\n";
×
NEW
256
                                continue;
×
257
                        }
258

259
                        // Compare values
NEW
260
                        double maxError = 0.0;
×
NEW
261
                        for (size_t i = 0; i < num_rows(fromHeader); ++i) {
×
NEW
262
                                for (size_t j = 0; j < num_cols(fromHeader); ++j) {
×
NEW
263
                                        double err = std::abs(fromHeader[i][j] - fromFile[i][j]);
×
NEW
264
                                        if (err > maxError) maxError = err;
×
265
                                }
266
                        }
267

268
                        // Allow for floating-point serialization differences (file stores limited precision)
NEW
269
                        if (maxError > 1e-5) {
×
NEW
270
                                ++nrOfFailedTests;
×
NEW
271
                                if (reportTestCases) std::cerr << "FAIL: " << name << " value mismatch (max error: " << maxError << ")\n";
×
272
                        }
NEW
273
                }
×
274

NEW
275
                return nrOfFailedTests;
×
NEW
276
        }
×
277

278
} }
279

280
// This is a program that we ran once to get the test matrices converted to data files
281
// 
282
// We have no code in the regression side of the test so CI is a NOP
283

284

285
// Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override
286
#define MANUAL_TESTING 0
287
// REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity
288
// It is the responsibility of the regression test to organize the tests in a quartile progression.
289
//#undef REGRESSION_LEVEL_OVERRIDE
290
#ifndef REGRESSION_LEVEL_OVERRIDE
291
#undef REGRESSION_LEVEL_1
292
#undef REGRESSION_LEVEL_2
293
#undef REGRESSION_LEVEL_3
294
#undef REGRESSION_LEVEL_4
295
#define REGRESSION_LEVEL_1 1
296
#define REGRESSION_LEVEL_2 1
297
#define REGRESSION_LEVEL_3 1
298
#define REGRESSION_LEVEL_4 1
299
#endif
300

301
int main()
1✔
302
try {
303
        using namespace sw::universal;
304
        using namespace sw::blas;
305

306
        std::string test_suite  = "test matrices serialization";
2✔
307
        std::string test_tag    = "test_matrices";
1✔
308
        bool reportTestCases    = true;
1✔
309
        int nrOfFailedTestCases = 0;
1✔
310

311
        ReportTestSuiteHeader(test_suite, reportTestCases);
1✔
312

313
#if MANUAL_TESTING
314

315
        // set up the set of test matrices
316
        std::vector<std::string> allTestMatrices = {
317
                "lambers_well",  //   2 x   2 well-conditioned matrix, K = 10.0
318
                "lambers_ill",   //   2 x   2 ill-conditioned matrix, K = 1.869050824603144e+08
319
                "h3",            //   3 x   3 test matrix, K = 1.8478e+11
320
                "int3",          //   3 x   3 integer test matrix (low condition number), K = 43.6115
321
                "faires74x3",    //   3 x   3 Burden Faires Ill-conditioned, K = 15999
322
                "q3",            //   3 x   3 Variable test matrix (edit entries), K = 1.2857e+06
323
                "q4",            //   4 x   4 test matrix, K = 2.35
324
                "q5",            //   5 x   5 test matrix, K = 1.1e+04
325
                "lu4",           //   4 x   4 test matrix, K = 11.6810
326
                "s4",            //   4 x   4 test matrix, K = 4.19
327
                "rand4",         //   4 x   4 random (low condition), K = 27.81
328
                "cage3",         //   5 x   5 Directed Weighted Graph, K = 1.884547e+01
329
                "b1_ss",         //   7 x   7 Chemical Process Simulation Problem, K = 1.973732e+02
330

331
                "west0132",      // 132 x 132 Chem. Simulation Process, K = 4.2e+11 
332
                "west0167",      // 167 x 167 Chemical Simulation Process, K = 2.827e+07
333
                "steam1",        // 240 x 240 Computational Fluid Dynamics, K = 2.827501e+07
334
                "steam3",        //  83 x  83 Computational Fluid Dynamics, K = 5.51e+10
335
                "fs_183_1",      // 183 x 183 2D/3D Problem Sequence, K = 1.5129e+13
336
                "fs_183_3",      // 183 x 183 2D/3D Problem Sequence, K = 1.5129e+13
337
                "bwm200",        // 200 x 200 Chemical simulation, K = 2.412527e+03
338
                "gre_343",       // 343 x 343 Directed Weighted Graph, K = 1.119763e+02
339
                "pores_1",       //  30 x  30 Computational Fluid Dynamics, K = 1.812616e+06
340
                "Stranke94",     //  10 x  10 Undirected Weighted Graph, K = 5.173300e+01
341
                "Trefethen_20",  //  20 x  20 Combinatorial Problem, K = 6.308860e+01
342
                "bcsstk01",      //  48 x  48 Structural Engineering, K = 8.8234e+05
343
                "bcsstk03",      // 112 x 112 Structural Engineering, K = 6.791333e+06
344
                "bcsstk04",      // 132 x 132 Structural Engineering, K = 2.292466e+06
345
                "bcsstk05",      // 153 x 153 Structural Engineering, K = 1.428114e+04
346
                "bcsstk22",      // 138 x 138 Structural Engineering, K = 1.107165e+05
347
                "lund_a",        // 147 x 147 Structural Engineering, K = 2.796948e+06
348
                "nos1",          // 237 x 237 Structural Engineering K = 1.991546e+07
349
                "arc130",        // 130 x 130    K = 6.0542e+10
350
                "saylr1",        // 238 x 238 Computational Fluid Dynamics, K = 7.780581e+08
351
                "tumorAntiAngiogenesis_2" // , K 1.9893e+10
352
        };
353
        GenerateMatrixDataFiles(allTestMatrices);
354

355
        ReportTestSuiteResults(test_suite, nrOfFailedTestCases);
356
        return EXIT_SUCCESS;
357
#else
358
        // Test the serialization/test_matrix.hpp functionality
359
        // Note: sw::blas::getTestMatrix() reads from .dat files (different from global getTestMatrix())
360
#if REGRESSION_LEVEL_1
361
        {
362
                // Test dataDirectory()
363
                std::string dataDir = sw::blas::dataDirectory();
1✔
364
                if (dataDir.empty()) {
1✔
NEW
365
                        ++nrOfFailedTestCases;
×
NEW
366
                        if (reportTestCases) std::cout << "FAIL: dataDirectory() returned empty\n";
×
367
                } else {
368
                        if (reportTestCases) std::cout << "PASS: dataDirectory() = " << dataDir << "\n";
1✔
369
                }
370

371
                // Test TestMatrixList is populated
372
                if (sw::blas::TestMatrixList.empty()) {
1✔
NEW
373
                        ++nrOfFailedTestCases;
×
NEW
374
                        if (reportTestCases) std::cout << "FAIL: TestMatrixList is empty\n";
×
375
                } else {
376
                        if (reportTestCases) std::cout << "PASS: TestMatrixList has " << sw::blas::TestMatrixList.size() << " matrices\n";
1✔
377
                }
378

379
                // Test ConditionNumber map is populated
380
                if (sw::blas::ConditionNumber.empty()) {
1✔
NEW
381
                        ++nrOfFailedTestCases;
×
NEW
382
                        if (reportTestCases) std::cout << "FAIL: ConditionNumber map is empty\n";
×
383
                } else {
384
                        if (reportTestCases) std::cout << "PASS: ConditionNumber map has " << sw::blas::ConditionNumber.size() << " entries\n";
1✔
385
                }
386

387
                // Test kappa() for known matrices (from serialization module)
388
                double k = sw::blas::kappa("lambers_well");
1✔
389
                if (std::abs(k - 10.0) < 0.001) {
1✔
390
                        if (reportTestCases) std::cout << "PASS: kappa(lambers_well) = " << k << "\n";
1✔
391
                } else {
NEW
392
                        ++nrOfFailedTestCases;
×
NEW
393
                        if (reportTestCases) std::cout << "FAIL: kappa(lambers_well) = " << k << " (expected 10.0)\n";
×
394
                }
395

396
                // Test kappa() for unknown matrix (should return 0.0 and print error)
397
                double unknownK = sw::blas::kappa("nonexistent_matrix");
1✔
398
                if (unknownK == 0.0) {
1✔
399
                        if (reportTestCases) std::cout << "PASS: kappa(unknown) = 0.0 (expected)\n";
1✔
400
                } else {
NEW
401
                        ++nrOfFailedTestCases;
×
NEW
402
                        if (reportTestCases) std::cout << "FAIL: kappa(unknown) = " << unknownK << " (expected 0.0)\n";
×
403
                }
404
        }
1✔
405

406
        // Test global getTestMatrix() from testsuite.hpp
407
        nrOfFailedTestCases += ReportTestResult(sw::blas::VerifyGlobalGetTestMatrix(reportTestCases), "testsuite.hpp", "getTestMatrix");
4✔
408

409
        // Test global kappa() from testsuite.hpp
410
        nrOfFailedTestCases += ReportTestResult(sw::blas::VerifyGlobalKappa(reportTestCases), "testsuite.hpp", "kappa");
4✔
411

412
        // Test matrix data values
413
        nrOfFailedTestCases += ReportTestResult(sw::blas::VerifyMatrixValues(reportTestCases), "matrices", "value verification");
3✔
414
#endif
415

416
#if REGRESSION_LEVEL_2
417
        {
418
                using namespace sw::numeric::containers;
419

420
                // Test loading a small matrix from file using sw::blas::getTestMatrix
421
                matrix<double> A = sw::blas::getTestMatrix("lambers_well");
422
                if (num_rows(A) == 2 && num_cols(A) == 2) {
423
                        if (reportTestCases) std::cout << "PASS: getTestMatrix(lambers_well) = 2x2\n";
424
                } else {
425
                        ++nrOfFailedTestCases;
426
                        if (reportTestCases) std::cout << "FAIL: getTestMatrix(lambers_well) = " << num_rows(A) << "x" << num_cols(A) << "\n";
427
                }
428

429
                // Test loading another matrix
430
                matrix<double> B = sw::blas::getTestMatrix("lu4");
431
                if (num_rows(B) == 4 && num_cols(B) == 4) {
432
                        if (reportTestCases) std::cout << "PASS: getTestMatrix(lu4) = 4x4\n";
433
                } else {
434
                        ++nrOfFailedTestCases;
435
                        if (reportTestCases) std::cout << "FAIL: getTestMatrix(lu4) = " << num_rows(B) << "x" << num_cols(B) << "\n";
436
                }
437

438
                // Test loading non-existent matrix (should return empty matrix)
439
                matrix<double> C = sw::blas::getTestMatrix("nonexistent_matrix");
440
                if (num_rows(C) == 0 && num_cols(C) == 0) {
441
                        if (reportTestCases) std::cout << "PASS: getTestMatrix(unknown) = 0x0 (expected)\n";
442
                } else {
443
                        ++nrOfFailedTestCases;
444
                        if (reportTestCases) std::cout << "FAIL: getTestMatrix(unknown) = " << num_rows(C) << "x" << num_cols(C) << "\n";
445
                }
446
        }
447

448
        // Test WriteMatrixDataFile function
449
        nrOfFailedTestCases += ReportTestResult(sw::blas::VerifyWriteMatrixDataFile(reportTestCases), "serialization", "WriteMatrixDataFile");
450

451
        // Compare file-loaded vs header-defined matrices
452
        nrOfFailedTestCases += ReportTestResult(sw::blas::VerifyFileVsHeaderMatrices(reportTestCases), "matrices", "file vs header comparison");
453
#endif
454

455
#if REGRESSION_LEVEL_3
456
        {
457
                using namespace sw::numeric::containers;
458

459
                // Test loading all matrices in TestMatrixList
460
                int loadedCount = 0;
461
                for (const auto& matrixName : sw::blas::TestMatrixList) {
462
                        matrix<double> M = sw::blas::getTestMatrix(matrixName);
463
                        if (num_rows(M) > 0 && num_cols(M) > 0) {
464
                                ++loadedCount;
465
                        } else {
466
                                ++nrOfFailedTestCases;
467
                                if (reportTestCases) std::cout << "FAIL: getTestMatrix(" << matrixName << ") load failed\n";
468
                        }
469
                }
470
                if (reportTestCases) std::cout << "Loaded " << loadedCount << "/" << sw::blas::TestMatrixList.size() << " matrices\n";
471
        }
472
#endif
473

474
#if REGRESSION_LEVEL_4
475
        {
476
                // Verify condition numbers are available for all matrices in TestMatrixList
477
                int kappaCount = 0;
478
                for (const auto& matrixName : sw::blas::TestMatrixList) {
479
                        double k = sw::blas::kappa(matrixName);
480
                        if (k > 0.0) {
481
                                ++kappaCount;
482
                        } else {
483
                                ++nrOfFailedTestCases;
484
                                if (reportTestCases) std::cout << "FAIL: kappa(" << matrixName << ") not found\n";
485
                        }
486
                }
487
                if (reportTestCases) std::cout << "Found kappa for " << kappaCount << "/" << sw::blas::TestMatrixList.size() << " matrices\n";
488
        }
489
#endif
490

491
        ReportTestSuiteResults(test_suite, nrOfFailedTestCases);
1✔
492
        return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
1✔
493
#endif
494
}
1✔
495
catch (char const* msg) {
×
496
        std::cerr << msg << std::endl;
×
497
        return EXIT_FAILURE;
×
498
}
×
499
catch (const sw::universal::universal_arithmetic_exception& err) {
×
500
        std::cerr << "Uncaught universal arithmetic exception: " << err.what() << std::endl;
×
501
        return EXIT_FAILURE;
×
502
}
×
503
catch (const sw::universal::universal_internal_exception& err) {
×
504
        std::cerr << "Uncaught universal internal exception: " << err.what() << std::endl;
×
505
        return EXIT_FAILURE;
×
506
}
×
507
catch (const std::runtime_error& err) {
×
508
        std::cerr << "Uncaught runtime exception: " << err.what() << std::endl;
×
509
        return EXIT_FAILURE;
×
510
}
×
511
catch (...) {
×
512
        std::cerr << "Caught unknown exception" << std::endl;
×
513
        return EXIT_FAILURE;
×
514
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc