~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to tests/norm.dia.ref

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// Copyright INRIA
 
3
 
 
4
eps=100*%eps;
 
5
 
 
6
// inf
 
7
 
 
8
if norm([1,2,3,-1,-2,-3],0)<>%inf then bugmes();quit;end
 
9
 
 
10
if ~isnan(norm([1,2,3,-1,-2,-3],%nan)) then bugmes();quit;end
 
11
 
 
12
if norm([])<>0 then bugmes();quit;end
 
13
 
 
14
// vector
 
15
 
 
16
x=[1,2,3,-4];
 
17
 
 
18
if abs(norm(x,1) - sum(abs(x))) > eps then bugmes();quit;end
 
19
 
 
20
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then bugmes();quit;end
 
21
 
 
22
if abs(norm(x,2) - norm(x)) > eps then bugmes();quit;end
 
23
 
 
24
p=0.5;
 
25
 
 
26
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
27
 
 
28
p=2.5;
 
29
 
 
30
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
31
 
 
32
if abs(norm(x,'inf') -maxi(abs(x))) > eps then bugmes();quit;end
 
33
 
 
34
if abs(norm(x,'inf') -norm(x,%inf)) > eps then bugmes();quit;end
 
35
 
 
36
if abs(norm(x,'fro') -norm(x,2)) > eps then bugmes();quit;end
 
37
 
 
38
 
 
39
// complex
 
40
 
 
41
x=x+%i*x;
 
42
 
 
43
if abs(norm(x,1) - sum(abs(x))) > eps then bugmes();quit;end
 
44
 
 
45
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then bugmes();quit;end
 
46
 
 
47
if abs(norm(x,2) - norm(x)) > eps then bugmes();quit;end
 
48
 
 
49
p=0.5;
 
50
 
 
51
// 100*%eps is needed for linux
 
52
 
 
53
if abs(norm(x,p) - maxi(abs(x))*sum((abs(x)/maxi(abs(x)))^p)^(1/p))> 100*%eps then bugmes();quit;end
 
54
 
 
55
p=2.5;
 
56
 
 
57
if abs(norm(x,p) - maxi(abs(x))*sum((abs(x)/maxi(abs(x)))^p)^(1/p))> 100*%eps then bugmes();quit;end
 
58
 
 
59
if abs(norm(x,'inf') -maxi(abs(x)))> eps then bugmes();quit;end
 
60
 
 
61
if abs(norm(x,'inf') -norm(x,%inf)) > eps then bugmes();quit;end
 
62
 
 
63
if abs(norm(x,'fro') -norm(x,2))> eps then bugmes();quit;end
 
64
 
 
65
 
 
66
// scalar
 
67
 
 
68
 
 
69
x=[1.23];
 
70
 
 
71
if abs(norm(x,1) - sum(abs(x))) > eps then bugmes();quit;end
 
72
 
 
73
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then bugmes();quit;end
 
74
 
 
75
if abs(norm(x,2) - norm(x)) > eps then bugmes();quit;end
 
76
 
 
77
p=0.5;
 
78
 
 
79
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
80
 
 
81
p=2.5;
 
82
 
 
83
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then bugmes();quit;end
 
84
 
 
85
if abs(norm(x,'inf') -maxi(abs(x))) > eps then bugmes();quit;end
 
86
 
 
87
if abs(norm(x,'inf') -norm(x,%inf)) > eps then bugmes();quit;end
 
88
 
 
89
if abs(norm(x,'fro') -norm(x,2)) > eps then bugmes();quit;end
 
90
 
 
91
 
 
92
// Matrices
 
93
 
 
94
a=rand(10,10,'g');
 
95
 
 
96
if abs(norm(a,1) - maxi(sum(abs(a),'r'))) > eps then bugmes();quit;end
 
97
 
 
98
if abs(norm(a,'inf') - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
99
 
 
100
if abs(norm(a,%inf) - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
101
 
 
102
if abs(norm(a,2) - maxi(svd(a))) > eps then bugmes();quit;end
 
103
 
 
104
if abs(norm(a,'fro') - norm(matrix(a,1,size(a,'*')),2)) > eps then bugmes();quit;end
 
105
 
 
106
 
 
107
a=a+%i*a;
 
108
 
 
109
if abs(norm(a,1) - maxi(sum(abs(a),'r'))) > eps then bugmes();quit;end
 
110
 
 
111
if abs(norm(a,'inf') - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
112
 
 
113
if abs(norm(a,%inf) - maxi(sum(abs(a),'c'))) > eps then bugmes();quit;end
 
114
 
 
115
if abs(norm(a,2) - maxi(svd(a))) > eps then bugmes();quit;end
 
116
 
 
117
if abs(norm(a,'fro') - norm(matrix(a,1,size(a,'*')),2)) > eps then bugmes();quit;end
 
118
 
 
119
 
 
120
 
 
121