test_matrices3.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
35 #include <stdlib.h>
36 
37 #include <qpOASES.hpp>
38 #include <qpOASES/UnitTesting.hpp>
39 
40 
41 #include "test_qrecipe_data.hpp"
42 
43 
45 int main( )
46 {
48 
49  int_t i;
50 
51  real_t errH=0.0;
52  real_t v[180];
53  real_t resHn[180];
54  real_t resHt[180];
55 
56  /* create sparse matrices */
57  SymSparseMat *H = new SymSparseMat(180, 180, H_ir, H_jc, H_val);
58 
59  H->createDiagInfo();
60 
61  real_t* H_full = H->full();
62 
63  SymDenseMat *Hd = new SymDenseMat(180,180,180,H_full);
64 
65  for( i=0; i<180; ++i )
66  v[i] = 2.0 * ((real_t)rand()) / ((real_t)RAND_MAX) - 1.0;
67 
68  Hd->times( 1, 1.0, v, 180, 0.0, resHn, 180);
69  Hd->transTimes(1, 1.0, v, 180, 0.0, resHt, 180);
70 
71  for ( i=0; i<180; ++i )
72  if ( getAbs(resHn[i] - resHt[i]) > errH)
73  errH = getAbs(resHn[i] - resHt[i]);
74 
75  fprintf(stdFile, "maximum difference in H*v vs. H'*v: %9.2e\n", errH);
76 
77  delete H;
78  delete[] H_full;
79  delete Hd;
80 
81 
82  QPOASES_TEST_FOR_TOL( errH,1e-15 )
83 
84  return TEST_PASSED;
85 }
86 
87 
88 /*
89  * end of file
90  */
Interfaces matrix-vector operations tailored to symmetric sparse matrices.
real_t getAbs(real_t x)
int main()
Interfaces matrix-vector operations tailored to symmetric dense matrices.
#define stdFile
returnValue transTimes(int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const
#define QPOASES_TEST_FOR_TOL(x, tol)
Definition: UnitTesting.hpp:61
#define TEST_PASSED
Definition: UnitTesting.hpp:45
#define v
returnValue times(int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const
double real_t
Definition: AD_test.c:10


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:12