type/scalar - Maple Programming Help

Home : Support : Online Help : Programming : Data Types : Type Checking : Types : type/scalar

type/scalar

check for scalar (in the matrix sense)

 Calling Sequence type(expr, scalar)

Parameters

 expr - expression

Description

 • Checks if expr is a scalar. This is the case if expr is algebraic and not a Vector or Matrix.
 • More precisely, expr is a scalar if:
 – expr is of type algebraic, and
 – expr is not the name of a procedure, table, or module, and
 – if the top-level type of expr is one of *, +, ., ^, &*, &+, and &^ (that is, if op(0, expr) is one of these operators), then all its arguments are scalars.

Examples

 > $a≔\mathrm{table}\left(\left['\mathrm{apple}'=3,'\mathrm{orange}'=5\right]\right)$
 ${a}{≔}{table}{}\left(\left[{\mathrm{orange}}{=}{5}{,}{\mathrm{apple}}{=}{3}\right]\right)$ (1)
 > $\mathrm{type}\left(a,\mathrm{scalar}\right)$
 ${\mathrm{false}}$ (2)
 > $\mathrm{type}\left(x,\mathrm{scalar}\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{type}\left(42,\mathrm{scalar}\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{type}\left(\mathrm{sin},\mathrm{scalar}\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{type}\left(x·y,\mathrm{scalar}\right)$
 ${\mathrm{true}}$ (6)
 > $v≔\mathrm{Vector}\left(\left[1,2,3\right]\right)$
 ${v}{≔}\left[\begin{array}{c}{1}\\ {2}\\ {3}\end{array}\right]$ (7)
 > $\mathrm{type}\left(x·v,\mathrm{scalar}\right)$
 ${\mathrm{false}}$ (8)