File: norm.dia.ref

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (121 lines) | stat: -rw-r--r-- 2,872 bytes parent folder | download | duplicates (2)
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
 
// Copyright INRIA
 
eps=100*%eps;
 
// inf
 
if norm([1,2,3,-1,-2,-3],0)<>%inf then bugmes();quit;end
 
if ~isnan(norm([1,2,3,-1,-2,-3],%nan)) then bugmes();quit;end
 
if norm([])<>0 then bugmes();quit;end
 
// vector
 
x=[1,2,3,-4];
 
if abs(norm(x,1) - sum(abs(x))) > eps then bugmes();quit;end
 
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then bugmes();quit;end
 
if abs(norm(x,2) - norm(x)) > eps then bugmes();quit;end
 
p=0.5;
 
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
p=2.5;
 
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
if abs(norm(x,'inf') -maxi(abs(x))) > eps then bugmes();quit;end
 
if abs(norm(x,'inf') -norm(x,%inf)) > eps then bugmes();quit;end
 
if abs(norm(x,'fro') -norm(x,2)) > eps then bugmes();quit;end
 
 
// complex
 
x=x+%i*x;
 
if abs(norm(x,1) - sum(abs(x))) > eps then bugmes();quit;end
 
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then bugmes();quit;end
 
if abs(norm(x,2) - norm(x)) > eps then bugmes();quit;end
 
p=0.5;
 
// 100*%eps is needed for linux
 
if abs(norm(x,p) - maxi(abs(x))*sum((abs(x)/maxi(abs(x)))^p)^(1/p))> 100*%eps then bugmes();quit;end
 
p=2.5;
 
if abs(norm(x,p) - maxi(abs(x))*sum((abs(x)/maxi(abs(x)))^p)^(1/p))> 100*%eps then bugmes();quit;end
 
if abs(norm(x,'inf') -maxi(abs(x)))> eps then bugmes();quit;end
 
if abs(norm(x,'inf') -norm(x,%inf)) > eps then bugmes();quit;end
 
if abs(norm(x,'fro') -norm(x,2))> eps then bugmes();quit;end
 
 
// scalar
 
 
x=[1.23];
 
if abs(norm(x,1) - sum(abs(x))) > eps then bugmes();quit;end
 
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then bugmes();quit;end
 
if abs(norm(x,2) - norm(x)) > eps then bugmes();quit;end
 
p=0.5;
 
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
p=2.5;
 
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
if abs(norm(x,'inf') -maxi(abs(x))) > eps then bugmes();quit;end
 
if abs(norm(x,'inf') -norm(x,%inf)) > eps then bugmes();quit;end
 
if abs(norm(x,'fro') -norm(x,2)) > eps then bugmes();quit;end
 
 
// Matrices
 
a=rand(10,10,'g');
 
if abs(norm(a,1) - maxi(sum(abs(a),'r'))) > eps then bugmes();quit;end
 
if abs(norm(a,'inf') - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
if abs(norm(a,%inf) - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
if abs(norm(a,2) - maxi(svd(a))) > eps then bugmes();quit;end
 
if abs(norm(a,'fro') - norm(matrix(a,1,size(a,'*')),2)) > eps then bugmes();quit;end
 
 
a=a+%i*a;
 
if abs(norm(a,1) - maxi(sum(abs(a),'r'))) > eps then bugmes();quit;end
 
if abs(norm(a,'inf') - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
if abs(norm(a,%inf) - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
if abs(norm(a,2) - maxi(svd(a))) > eps then bugmes();quit;end
 
if abs(norm(a,'fro') - norm(matrix(a,1,size(a,'*')),2)) > eps then bugmes();quit;end