Line data Source code
1 : /*
2 : * File: TestQuadOverAffine.cpp
3 : * Author: Pantelis Sopasakis
4 : *
5 : * Created on Aug 27, 2015, 2:19:01 PM
6 : */
7 :
8 : #include "TestQuadOverAffine.h"
9 : #include "MatrixFactory.h"
10 : #include "QuadOverAffine.h"
11 : #include <cmath>
12 :
13 1 : CPPUNIT_TEST_SUITE_REGISTRATION(TestQuadOverAffine);
14 :
15 1 : TestQuadOverAffine::TestQuadOverAffine() {
16 1 : }
17 :
18 2 : TestQuadOverAffine::~TestQuadOverAffine() {
19 2 : }
20 :
21 1 : void TestQuadOverAffine::setUp() {
22 1 : }
23 :
24 1 : void TestQuadOverAffine::tearDown() {
25 1 : }
26 :
27 1 : void TestQuadOverAffine::testQuadOverAffine() {
28 1 : int n = 8;
29 1 : int s = 4;
30 1 : Matrix Q = MatrixFactory::MakeRandomMatrix(n, n, 0.0, 1.0, Matrix::MATRIX_DENSE);
31 2 : Matrix A = MatrixFactory::MakeRandomMatrix(s, n, 0.0, -5.0, Matrix::MATRIX_DENSE);
32 :
33 2 : Matrix q = MatrixFactory::MakeRandomMatrix(n, 1, 0.0, 1.0, Matrix::MATRIX_DENSE);
34 2 : Matrix b = MatrixFactory::MakeRandomMatrix(s, 1, 0.0, 1.0, Matrix::MATRIX_DENSE);
35 :
36 : QuadOverAffine * qoa;
37 1 : qoa = new QuadOverAffine(Q, q, A, b);
38 1 : _ASSERT_NEQ(NULL, qoa);
39 :
40 2 : Matrix y = MatrixFactory::MakeRandomMatrix(n, 1, 0.0, 1.0, Matrix::MATRIX_DENSE);
41 1 : double fstar = 0.0;
42 2 : Matrix grad;
43 1 : int status = qoa->callConj(y, fstar, grad);
44 1 : _ASSERT_EQ(ForBESUtils::STATUS_OK, status);
45 1 : _ASSERT_NOT(std::abs(fstar) < 1e-7);
46 :
47 2 : _ASSERT_OK(delete qoa);
48 :
49 4 : }
50 :
|