summaryrefslogtreecommitdiff
path: root/src/matrixOperations/infiniteNorm/testMatrixInfiniteNorm.c
blob: a4116f6c039cbd46980b9829d6bba0f975e960cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008-2008 - INRIA - Allan SIMON
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 */

#include <assert.h>
#include <stdio.h>
#include "infiniteNorm.h"


#define LEADDIM 10

#define DMATRIX_IN  {0.15869047446176410,0.80895681912079453,0.72621259605512023,0.18993748771026731,\
 0.43964602379128337,0.37921421090140939,0.95195201179012656,0.59145097108557820,\
 0.70597065938636661,0.62873698258772492,\
0.62407150492072105,0.68317985069006681,0.70999773032963276,0.25839814636856318,\
 0.65407369285821915,0.76687160786241293,0.71278580836951733,0.68067426700145006,\
 0.70181696489453316,0.28785153012722731,\
0.63760355720296502,0.03401931514963508,0.47457459988072515,0.09878737432882190,\
 0.58781063789501786,0.60066213225945830,0.11923700617626309,0.07392961112782359,\
 0.40879997471347451,0.3292048736475408,\
0.42704886104911566,0.23805456422269344,0.9438692079856992,0.06199027225375175,\
 0.60208318661898375,0.78567356057465076,0.50091631803661585,0.94336947053670883,\
 0.06362213846296072,0.47192330472171307,\
0.10716815060004592,0.94920115964487195,0.14596485672518611,0.04034968325868249,\
 0.04535020282492042,0.73871155502274632,0.32900535268709064,0.12863306934013963,\
 0.06573933875188231,0.33537696348503232,\
0.23822965659201145,0.21827886346727610,0.07141010463237762,0.74001471605151892,\
 0.20294443331658840,0.55442603398114443,0.48089468106627464,0.20190807711333036,\
 0.53310041315853596,0.55530697200447321,\
0.94629473658278584,0.61546878470107913,0.67337385797873139,0.61626600986346602,\
 0.78442738251760602,0.99291495559737086,0.33036959776654840,0.19693034281954169,\
 0.03315818728879094,0.11960808141157031,\
0.45766852516680956,0.83135433867573738,0.65369247179478407,0.6583583448082209,\
 0.26375361625105143,0.97574284672737122,0.63044753577560186,0.89286901615560055,\
 0.31578356493264437,0.76139996573328972,\
0.89644787041470408,0.77340125897899270,0.19968961318954825,0.25145971449092031,\
 0.43832763982936740,0.37096222722902894,0.21171907847747207,0.46179189579561353,\
 0.37858232436701655,0.47909884760156274,\
0.44384705275297165,0.4244190966710448,0.60141251794993877,0.38433500844985247,\
 0.86648589745163918,0.30322382133454084,0.44860231317579746,0.62512917164713144,\
 0.46195234358310699,0.28169692959636450}

#define DRESULT_OUT 6.44107022602111101

#define FMATRIX_IN  {0.15869047446176410f,0.80895681912079453f,0.72621259605512023f,0.18993748771026731f,\
 0.43964602379128337f,0.37921421090140939f,0.95195201179012656f,0.59145097108557820f,\
 0.70597065938636661f,0.62873698258772492f,\
0.62407150492072105f,0.68317985069006681f,0.70999773032963276f,0.25839814636856318f,\
 0.65407369285821915f,0.76687160786241293f,0.71278580836951733f,0.68067426700145006f,\
 0.70181696489453316f,0.28785153012722731f,\
0.63760355720296502f,0.03401931514963508f,0.47457459988072515f,0.09878737432882190f,\
 0.58781063789501786f,0.60066213225945830f,0.11923700617626309f,0.07392961112782359f,\
 0.40879997471347451f,0.3292048736475408f,\
0.42704886104911566f,0.23805456422269344f,0.9438692079856992f,0.06199027225375175f,\
 0.60208318661898375f,0.78567356057465076f,0.50091631803661585f,0.94336947053670883f,\
 0.06362213846296072f,0.47192330472171307f,\
0.10716815060004592f,0.94920115964487195f,0.14596485672518611f,0.04034968325868249f,\
 0.04535020282492042f,0.73871155502274632f,0.32900535268709064f,0.12863306934013963f,\
 0.06573933875188231f,0.33537696348503232f,\
0.23822965659201145f,0.21827886346727610f,0.07141010463237762f,0.74001471605151892f,\
 0.20294443331658840f,0.55442603398114443f,0.48089468106627464f,0.20190807711333036f,\
 0.53310041315853596f,0.55530697200447321f,\
0.94629473658278584f,0.61546878470107913f,0.67337385797873139f,0.61626600986346602f,\
 0.78442738251760602f,0.99291495559737086f,0.33036959776654840f,0.19693034281954169f,\
 0.03315818728879094f,0.11960808141157031f,\
0.45766852516680956f,0.83135433867573738f,0.65369247179478407f,0.6583583448082209f,\
 0.26375361625105143f,0.97574284672737122f,0.63044753577560186f,0.89286901615560055f,\
 0.31578356493264437f,0.76139996573328972f,\
0.89644787041470408f,0.77340125897899270f,0.19968961318954825f,0.25145971449092031f,\
 0.43832763982936740f,0.37096222722902894f,0.21171907847747207f,0.46179189579561353f,\
 0.37858232436701655f,0.47909884760156274f,\
0.44384705275297165f,0.4244190966710448f,0.60141251794993877f,0.38433500844985247f,\
 0.86648589745163918f,0.30322382133454084f,0.44860231317579746f,0.62512917164713144f,\
 0.46195234358310699f,0.28169692959636450f}

#define FRESULT_OUT 6.44107022602111101f

static void sinfnormaTest(void) {
    
    float in[] = FMATRIX_IN ;
    
    float out = 0;
    
    float result = FRESULT_OUT ;
    
    out = sinfnorma ( in , LEADDIM , LEADDIM );
    
    printf ( "\t\t  out : %e\tresult : %e\tassert : %e \n" , out , result , fabs ( out - result ) / fabs( out) ) ;
    assert ( fabs ( out - result ) / fabs( out) < 1e-6 ) ;
    
    
    
}

static void dinfnormaTest(void) {
    
    double in[] = DMATRIX_IN ;
    
    double out = 0;
    
    double result = DRESULT_OUT ;
    
    out = dinfnorma ( in , LEADDIM , LEADDIM );
    
    printf ( "\t\t  out : %e\tresult : %e\tassert : %e \n" , out , result , fabs ( out - result ) / fabs( out) ) ;
    assert ( fabs ( out - result ) / fabs( out) < 1e-14 ) ;
    
    
    
}


static int testInfiniteNorm(void) {

  printf("\n>>>> Matrix Exponential Tests\n");
  printf("\t>>>> Matrix Double Realt Tests\n");  
  dinfnormaTest();

  printf("\n\n\t>>>> Matrix Float Realt Tests\n");     
  sinfnormaTest();
  
 /* printf("\n\n\n");
  printf("\t>>>> Matrix Float Complex Tests\n");      
  cexpmaTest();  
    
  printf("\n\n\n");
  printf("\t>>>> Matrix Double Complex Tests\n");  
  zexpmaTest();*/

  return 0;
}



int main(void) {
  assert(testInfiniteNorm() == 0);
  return 0;
}