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

« back to all changes in this revision

Viewing changes to tests/norm.tst

  • 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
// Copyright INRIA
 
2
eps=100*%eps;
 
3
// inf 
 
4
if norm([1,2,3,-1,-2,-3],0)<>%inf then pause,end 
 
5
if ~isnan(norm([1,2,3,-1,-2,-3],%nan)) then pause,end 
 
6
if norm([])<>0 then pause,end
 
7
// vector
 
8
x=[1,2,3,-4];
 
9
if abs(norm(x,1) - sum(abs(x))) > eps then pause,end
 
10
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then pause,end
 
11
if abs(norm(x,2) - norm(x)) > eps then pause,end
 
12
p=0.5;
 
13
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then pause,end
 
14
p=2.5;
 
15
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then pause,end
 
16
if abs(norm(x,'inf') -maxi(abs(x))) > eps then pause,end
 
17
if abs(norm(x,'inf') -norm(x,%inf)) > eps then pause,end
 
18
if abs(norm(x,'fro') -norm(x,2)) > eps then pause,end
 
19
 
 
20
// complex 
 
21
x=x+%i*x;
 
22
if abs(norm(x,1) - sum(abs(x))) > eps then pause,end
 
23
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then pause,end
 
24
if abs(norm(x,2) - norm(x)) > eps then pause,end
 
25
p=0.5;
 
26
// 100*%eps is needed for linux 
 
27
if abs(norm(x,p) - maxi(abs(x))*sum((abs(x)/maxi(abs(x)))^p)^(1/p))> 100*%eps then pause,end
 
28
p=2.5;
 
29
if abs(norm(x,p) - maxi(abs(x))*sum((abs(x)/maxi(abs(x)))^p)^(1/p))> 100*%eps then pause,end
 
30
if abs(norm(x,'inf') -maxi(abs(x)))> eps then pause,end
 
31
if abs(norm(x,'inf') -norm(x,%inf)) > eps then pause,end
 
32
if abs(norm(x,'fro') -norm(x,2))> eps then pause,end
 
33
 
 
34
// scalar 
 
35
 
 
36
x=[1.23];
 
37
if abs(norm(x,1) - sum(abs(x))) > eps then pause,end
 
38
if abs(norm(x,2) - sqrt(sum(abs(x).*abs(x)))) > eps then pause,end
 
39
if abs(norm(x,2) - norm(x)) > eps then pause,end
 
40
p=0.5;
 
41
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then pause,end
 
42
p=2.5;
 
43
if abs(norm(x,p) - sum(abs(x)^p)^(1/p)) > eps then pause,end
 
44
if abs(norm(x,'inf') -maxi(abs(x))) > eps then pause,end
 
45
if abs(norm(x,'inf') -norm(x,%inf)) > eps then pause,end
 
46
if abs(norm(x,'fro') -norm(x,2)) > eps then pause,end
 
47
 
 
48
// Matrices 
 
49
a=rand(10,10,'g');
 
50
if abs(norm(a,1) - maxi(sum(abs(a),'r'))) > eps then pause,end
 
51
if abs(norm(a,'inf') - maxi(sum(abs(a),'c'))) > eps then pause,end
 
52
if abs(norm(a,%inf) - maxi(sum(abs(a),'c'))) > eps then pause,end
 
53
if abs(norm(a,2) - maxi(svd(a))) > eps then pause,end
 
54
if abs(norm(a,'fro') - norm(matrix(a,1,size(a,'*')),2)) > eps then pause,end
 
55
 
 
56
a=a+%i*a;
 
57
if abs(norm(a,1) - maxi(sum(abs(a),'r'))) > eps then pause,end
 
58
if abs(norm(a,'inf') - maxi(sum(abs(a),'c'))) > eps then pause,end
 
59
if abs(norm(a,%inf) - maxi(sum(abs(a),'c'))) > eps then pause,end
 
60
if abs(norm(a,2) - maxi(svd(a))) > eps then pause,end
 
61
if abs(norm(a,'fro') - norm(matrix(a,1,size(a,'*')),2)) > eps then pause,end
 
62
 
 
63
 
 
64