<< Div SYMSCI Toolbox Evalf >>

SYMSCI Toolbox >> SYMSCI Toolbox > Elem

Elem

access element of symbolic object

Calling Sequence

e: Elem( v, i )
e: v( i )
e: Elem( A, i, j )
e: A( i, j )
B: Elem( A, i, j, s )
A( i, j ) = s

Arguments

v

vector or set of symbolic scalars

A

matrix of symbolic scalars

i

vector of non-negative integers

j

vector non-negative integers

s

symbolic scalar, matrix of symbolic scalars,

matrix of integers, doubles, or strings

e

symbolic scalar, vector or matrix of symbolic scalars

B

matrix of symbolic scalars

Description

Elem( v, i )
v(i)

Returns the i-th element of a vector or set v as symbolic scalar.

If i is a vector of indices, then the corresponding subvector of v is returned.

Elem( A, i, j )
A( i, j )

Returns the element in row i and column j of a matrix A as symbolic scalar.

If i or j are vectors of indices, then the corresponding submatrix of A is returned.

Elem( A, i, j, s)
A( i, j ) = s

Sets the element in row i and column j of a matrix A in-place to s and returns the modified matrix A.

If i or j are vectors of indices, then every element of the corresponding submatrix of A is set to a scalar s or the corresponding submatrix of A if filled one-by-one with the elements of a matrix s.

Examples

// create a vector
v = %(Vec())
v: int32(1)
v: int32(2)
v: int32(3)

// get 2nd element of v
v(2)

// get 1st and 3rd element of v as vector
v([1,3])

// create a empty set
S = %(Set())

// insert elements
S: "a"
S: "b"
S: "c"

// get elements of S
S(1)
S(2)
S(3)

// create (3,3)-matrix of zeros
A = %(Zeros(3,3))

// create a symbol
x = %(Sym("x"))

// set (2,2)-element of A
A(2,2) = 2*x+5

// get a submatrix of A
A(1:2,1:3)

// set a submatrix of A
A(2:3,2:3) = 5*Ones(2,2)
 
// clean-up
reset();
clear v S A x;

See Also

Authors

Bibliography

SymEngine: C++ library for fast symbolic manipulation.


Report an issue
<< Div SYMSCI Toolbox Evalf >>