<< mps_det mpscilab mps_div >>

mpscilab >> mpscilab > mps_diag

mps_diag

Diagonal insertion and extraction.

Calling Sequence

mps_diag( rop, op, [k] )

Overloaded usage:

rop = diag( op, [k] )

Arguments

rop

multi-precision matrix

op

Scilab or multi-precision matrix

k

Scalar integer

Description

For op a matrix, will extract a diagonal into rop. For op a column or row vector diag() will set the corresponding diagonal of rop

mps_diag( rop, op, [k] )

Either set or get the k-th diagonal.

rop = diag( op, [k] )

Overloaded Scilab primitive diag(). Create a multi-precision matrix the correct size and precision for the requested operation.

Examples

// Extract the main diagonal of a matrix.
A = [ 1 2 3;
      4 5 6;
      7 8 9 ]
mpsA = mps_init2(A,100)
rop = mps_init(3,1,100)
mps_diag(rop, mpsA)

// Extract the first diagonal of a matrix.
A = [ 1 2 3;
      4 5 6;
      7 8 9 ]
mpsA = mps_init2(A,100)
rop = mps_init(2,1,100)
mps_diag(rop, mpsA, 1)

// Set the main diagonal of a matrix.
A = [ 1 2 3 4 ]
mpsA = mps_init2(A,100)
rop = mps_init(4,4,100)
mps_diag(rop, mpsA)

// Overloaded extraction.
A = [ 1 2 3;
      4 5 6;
      7 8 9 ]
mpsA = mps_init2(A,100)
rop = diag(mpsA)
<< mps_det mpscilab mps_div >>