<< or Matrix operations sign >>

Scilab Help >> Elementary Functions > Matrix operations > prod

prod

product of array elements

Syntax

y=prod(x)
y=prod(x,orientation)
y=prod(x,outtype)
y=prod(x,orientation,outtype)

Arguments

x

an array of reals, complex, booleans, polynomials or rational fractions.

orientation

it can be either

  • a string with possible values "*", "r", "c" or "m"

  • a number with positive integer value

outtype

a string with possible values "native" or "double".

y

scalar or array

Description

For an array x, y=prod(x) returns in the scalar y the product of all the elements of x.

y=prod(x,orientation) returns in y the product of x along the dimension given by orientation:

The outtype argument rules the way the product is done:

This function applies with identical rules to sparse matrices.

Examples

A=[1,2;3,4];
prod(A)
prod(A,1)

I=uint8([2 95 103;254 9 0])
prod(I) //native evaluation
prod(I,"double")
prod(I,2,"double")

s=poly(0,"s");
P=[s,%i+s;s^2,1];
prod(P),
prod(P,2)

B=[%t %t %f %f];
prod(B) //evaluation in float
prod(B,"native") //similar to and(B)

See also


Report an issue
<< or Matrix operations sign >>