<< min QD: 32 bytes decimal arithmetics qdones >>

DD_QD (MuPAT) >> DD_QD (MuPAT) > QD: 32 bytes decimal arithmetics > norm

norm

Norm 1|2|p|inf|fro of a matrix of QD numbers

Syntax

qd = norm(A)
qd = norm(A, 1)
qd = norm(A, 2)
qd = norm(A, p)
qd = norm(A, %inf|'inf')
qd = norm(A, 'fro'|'f')

Parameters

A

matrix of QD real numbers. Row vectors are transposed, in order to make their norm matching the correspond matrix-case definition.
The 2-norm is presently restricted to input vectors.

qd

single QD number: the norm of A.

Description

The native norm() Scilab function is overloaded in order to process DD and QD matrices.

As a reminder, here are the norm definitions:
1L-1 norm: max(sum(abs(A),'r'))
2Euclidian norm.
p L-p norm: sum(abs(A).^p)^(1/p), with p>2: Not implemented
inf Infinity norm: max(sum(abs(A),'c')). For a vector (forced to a column A), this is max(abs(A))
fro Frobenius norm: sqrt(sum(diag(A'*A))). For a vector (forced to a column A), this matches the euclidian norm.

Examples

Norm of a matrix:

q = d2qd([-2:2; 1:5])
format(20)

norm(q,1)
norm(q.d,1)

norm(q, %inf)
norm(q.d, %inf)

norm(q, 'fro')
norm(q.d, 'fro')

format(10)
--> q = d2qd([-2:2; 1:5])
 q  = 
[d1]
  -2.  -1.   0.   1.   2.
   1.   2.   3.   4.   5.
[d2] zeros(2,5)
[d3] zeros(2,5)
[d4] zeros(2,5)

--> format(20)

--> norm(q,1)
 ans  =
   7.00000000000000000000000000000000000000000000000000000000000000E0

--> norm(q.d,1)
 ans  =
   7.

   
--> norm(q, %inf)
 ans  =
   1.50000000000000000000000000000000000000000000000000000000000000E1

--> norm(q.d, %inf)
 ans  =
   15.


--> norm(q, 'fro')
 ans  =
   8.06225774829854965236661323030377113113439630560857338793659239E0

--> norm(q.d, 'fro')
 ans  =
   8.06225774829855090

L2-Norm of a vector:

format(20)

q = d2qd(1:3)'
norm(q)
norm(q.d)

format(10)
--> q = d2qd(1:3)'
 q  = 
[d1]
   1.
   2.
   3.
[d2] zeros(3,1)
[d3] zeros(3,1)
[d4] zeros(3,1)

--> norm(q)
 ans  =
   3.74165738677394138558374873231654930175601980777872694630374547E0

--> norm(q.d)
 ans  =
   3.74165738677394090

See Also

Authors

Copyright (C) 2011 - Tsubasa Saito Copyright (C) 2018 - Samuel GOUGEON

Report an issue
<< min QD: 32 bytes decimal arithmetics qdones >>