<< mps_nearfloat mpscilab mps_ones >>

mpscilab >> mpscilab > mps_neg

mps_neg

Element-wise negation

Calling Sequence

mps_neg( rop, op )
rop = mps_neg( op )

Overloaded usage:

rop = -op

Arguments

rop

multi-precision matrix

op

Scilab or multi-precision matrix

Description

Returns the element-wise negation of the entries of op

mps_neg( rop, op )

Sets every element of rop to the negative value of op.

rop = mps_neg( op )

Creates a multi-precision matrix the same size and precision as op containing the result.

rop = -op

Overloaded Scilab unary operator -. Creates a multi-precision matrix the same size and precision as op containing the result.

Usage notes

Like most mps functions the mps_neg( rop, op ) form is faster and can reuse the space of an existing matrix but requires an already initialized operand. Also, the same form can be used to perform an in-place operation when rop and op are the same.

Examples

// Standard usage.
A = [1 -2; 3 -4]
mpsA = mps_init2(A,100)
rop = mps_init(2,2,100)
mps_neg(rop,mpsA)

// Same but using a Scilab matrix as input.
A = [1 -2; 3 -4]
rop = mps_init(2,2,100)
mps_neg(rop,A)

// In-place computation.
A = [1 -2; 3 -4]
mpsA = mps_init2(A,100)
mps_neg(mpsA)

// Overloaded usage.
A = [1 -2; 3 -4]
mpsA = mps_init2(A,100)
rop = -mpsA

See Also

<< mps_nearfloat mpscilab mps_ones >>