[Contents] [TitleIndex] [WordIndex

Conversion Functions - Examples

Example 1

Given x (rhs), the abs function returns the absolute value of the elements x (lhs). When x is complex abs(x) is the modulus complex of the elements x.

In the real case rhs and lhs have the same size, type(Double always) and properties, but in the complex case the properties are different (rhs is complex and lhs is real).

So if the rhs dimension is known then sci_abs affects the same dimension to lhs, else it affectes the unknown dimension to lhs (defined by -1). However Even if the rhs property is unknown, sci_abs affects a Real property to lhs.

In this case it's easy to write the conversion function which uses 3 main functions:

getrhs: to get the rhs tlist

Rhs: to create a new rhs tlist

Type: to change the lhs type

sci_abs

function [tree]=sci_abs(tree)
A=getrhs(tree)
tree.rhs=Rhs(A)
tree.lhs(1).dims=A.dims
tree.lhs(1).type=Type(Double,Real)
endfunction

Example 2

sci_max

function [tree]=sci_max(tree)

2022-09-08 09:27