This section describes functions from file std.ct.
[y] = BatchMode()
BatchMode() returns 1 if this Tela process is in batch mode
(command line switch -b), otherwise 0.
See also:
SilentMode
,
VerboseMode
.
[y] = HeavisideTheta(x)
y = HeavisideTheta(x) returns 1 if x>=0 and 0 if x<0.
x must be real. If x is array, the operation is applied componentwise.
See also:
sign
.
Error codes:
-1: Complex or nonnumeric input argument
[y] = Im(x)
y = Im(x) computes the imaginary part of a complex quantity x.
If x is real or integer, the result is zero.
If x is an array, the operation is applied componentwise.
See also:
Re
,
conj
,
arg
.
Error codes:
-1: Nonnumeric input argument
[y] = Re(x)
y = Re(x) computes the real part of a complex quantity x.
If x is real or integer, it is returned as such.
If x is an array, the operation is applied componentwise.
See also:
Im
,
conj
,
arg
.
Error codes:
-1: Nonnumeric input argument
[y] = SilentMode()
SilentMode() returns 1 if this Tela process is in silent mode
(command line switch -s), otherwise 0.
See also:
BatchMode
,
VerboseMode
.
[y] = VerboseMode(;x)
VerboseMode() returns 1 if this Tela process is in verbose mode
(command line switch -v), otherwise 0.
VerboseMode(on) and VerboseMode(off) set the verbose mode on
and off, respectively. They return the old mode setting.
See also:
SilentMode
,
BatchMode
.
Error codes:
1: Argument not integer
[y] = abs2(x)
y = abs2(x) computes the square of the absolute value of x.
If x is real or integer, the result is just the square of x.
If x is complex, the result is equal to x*conj(x).
If x is an array, the operation is applied componentwise.
Error codes:
-1: Nonnumeric input argument
[y] = acos(x)
y = acos(x) computes the arc cosine of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
[y] = all(x)
all(x) returns 1 if all elements of x are nonzero,
and 0 otherwise.
x must be an integer array or scalar.
See also:
any
.
Error codes:
1: Argument not integer or IntArray
[y] = any(x)
any(x) returns 1 if at least one element of x is nonzero,
and 0 otherwise.
x must be a integer array or scalar.
See also:
all
.
Error codes:
1: Argument not integer or IntArray
[phi] = arg(z)
arg(z) returns the argument of a complex quantity
(in radians). The result is between -pi and pi.
If z is a complex array, the operation is applied
componentwise.
See also:
Re
,
Im
,
conj
.
Error codes:
1: Nonnumeric argument
[y] = asin(x)
y = asin(x) computes the arc sine of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
[y] = atan(x)
y = atan(x) computes the arc tangent of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
See also:
atan2
.
[z] = atan2(y,x)
z = atan2(y,x) computes the arcus tangent of y/x using the signs
of both arguments to determine the quadrant of the return value.
The input argument must be integer or real scalars and the
return value is real.
See also:
atan
.
Error codes:
-1: Bad input argument
[] = autosource(fn...)
autosource("file.t","name1","name2",...) tags symbols
name1, name2,... such that the command source("file.t")
is effectively executed when any of the symbols name
is used. This is load-on-demand.
See also:
source
.
Error codes:
1: Argument not a string
[] = cd(fn)
cd("pathname") will change the current directory to "pathname".
Error codes:
1: Input argument not a string or a char
2: Directory not found
[y] = ceil(x)
ceil(x) returns the smallest integer which is larger than x.
x must be integer or real scalar or array. If it is an array,
the operation is applied componentwise.
See also:
floor
.
Error codes:
-1: Complex or nonnumeric input argument
[y] = conj(x)
y = conj(x) computes the complex conjugate of x.
Real and integer arguments are returned as such.
If x is an array, the operation is applied componentwise.
See also:
Re
,
Im
,
arg
.
[y] = cos(x)
y = cos(x) computes the cosine function of x.
If x is complex, the result is complex, otherwise real.
The argument must be in radians.
If x is an array, the operation is applied componentwise.
[y] = cosh(x)
y = cosh(x) computes the hyperbolic cosine function of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
[y] = cot(x)
y = cot(x) is the cotangent function
cot(x) = 1/tan(x) = cos(x)/sin(x).
[t] = cputime()
cputime() returns the CPU time in seconds used by the current
tela session.
See also:
tic
,
toc
.
[y] = csc(x)
y = csc(x) is the cosecant function
csc(x) = 1/sin(x).
[y] = diag(x)
diag(V) (V is a vector) returns a square diagonal matrix,
whose diagonal elements are given by V.
diag(M) (M is a matrix) returns the main diagonal of M
as a vector.
Error codes:
-1: Input array not vector or matrix
[] = disasm(fn)
disasm(f) produces disassembly listing of function f.
Error codes:
1: Argument not a Tela function
[] = dump()
dump() dumps the stack. Useful for debugging only.
[] = echo(x)
echo(on) and echo(off) set the echo mode on and off.
The mode is off by default. When echo mode is on, the source
code is echoed as it is parsed.
*** NOTE: Currently this function has no effect! ***
Error codes:
1: Input argument not an integer
[] = eval(s)
eval("string") executes string as a Tela command, as it had been
typed from the keyboard.
The evaluation is done in global context. The symbols appearing
in the string refer to the global ones.
See also:
evalexpr
.
Error codes:
1: Argument not a string or char
[y] = evalexpr(s)
evalexpr("expression") executes string as a Tela command,
returning its value in y.
The evaluation is done in global context. The symbols appearing
in the string refer to the global ones.
See also:
eval
.
Error codes:
1: Argument not a string or char
[] = exit()
exit() stops Tela. quit() is synonym for exit().
[y] = exp(x)
y = exp(x) computes the exponent function of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
[y] = find(x)
I=find(V) returns the index vector I=(i) for which
V[i] is nonzero. V must be an integer array. The length
of I is equal to the number of nonzeros in V.
If V is multidimensional, it is used in flattened form.
See also:
any
,
all
,
flatten
.
Error codes:
1: Argument not integer vector
[y] = flatten(;x)
flatten(x) returns the array x flattened to a vector.
If x is not an array, it is returned as is.
x = flatten() flattens x "in place". This is much faster
(it works in constant time) than to do x = flatten(x),
since no data movement is involved.
[y] = floor(x)
floor(x) returns the largest integer which is smaller than x.
x must be integer or real scalar or array. If it is an array,
the operation is applied componentwise.
See also:
ceil
.
Error codes:
-1: Complex or nonnumeric input argument
[] = format(str...)
format("format-string",arg1,arg2,...) prints "format-string"
to standard output, replacing occurrences of `format-spec`
with consecutive args. `Format-spec` is either empty, i.e. ``,
or of the form
`[-]w[.d]`.
Here w is the field width (unsigned integer) and d is the number
of significant digits, also unsigned integer. By default the
argument is printed left-justified, but the optional minus sign
dictates right justification. The backquote character ` can be
produced by writing it three times: ```.
Hint: You can add any number of spaces before the closing backquote,
for example `20.7 `.
These spaces do not affect the output. This feature can be used
to justify source code lines.
See also:
sformat
.
Error codes:
1: First argument not a string or char
[y] = getenv(varname)
getenv("envvar") returns the value of environment variable
"envvar", or VOID if such variable is not defined in
the UNIX environment.
Error codes:
-1: Argument not a string or char
[] = help(;fn)
help(function-name) or help("help-item") displays the help information
associated with a given function or a given help item. On command line
you may use the abbreviation
?help-item
or
help help-item
These forms are translated to help("help-item") before parsing.
First tries:
help operators
help special
help if
help for
help function
...
Error codes:
1: Item not found
2: Cannot open help file
[B] = herm(A; P)
herm(A) is the same as conj(transpose(A)).
herm(A,P) is the same as conj(transpose(A,P)).
You can abbreviate "herm(A)" as "A'".
See also:
transpose
.
Error codes:
-1: Permutation argument not integer array
-2: Permutation argument of bad rank or size
-3: Permutation argument contains invalid integers
[] = info()
info() shows information about various class sizes for this Tela implementation.
It also prints the total counts of Tnode, Tprg and Tobject objects at the moment.
[s] = input_string()
input_string() waits for an input line from the keyboard
and returns it as a string. The newline is not included
in the result.
If the string is enclosed in double quotes, they are removed.
Error codes:
-1: EOF encountered.
[y] = isCfunction(x)
isCfunction(x) returns 1 if x is a C-tela function.
and 0 otherwise.
See also:
isfunction
,
isTfunction
.
[y] = isTfunction(x)
isTfunction(x) returns 1 if x is a function written in Tela
and 0 otherwise.
See also:
isfunction
,
isCfunction
.
[y] = isarray(x)
isarray(x) returns 1 if x is an array and 0 if it is not.
See also:
isscalar
,
isvector
,
ismatrix
.
[y] = ischar(x)
ischar(x) returns 1 if x is a character and 0 otherwise.
See also:
isstring
,
isstr
.
[y] = iscomplex(x)
iscomplex(x) returns 1 if x is a complex array or scalar,
and 0 if it is real or integer or a nonnumeric object.
See also:
isreal
,
isfloat
,
isint
.
[y] = isdefined(x)
isdefined(x) returns 1 if x is not undefined and 0 if
it is undefined. Optional function arguments are undefined
if not assigned by the caller; isdefined can be used
inside the function to test whether this is the case.
See also:
isundefined
.
[y] = isfinite(x)
isfinite(x) returns 1 if x is a finite number and 0 otherwise.
If x is array, the operation is applied componentwise.
If x is non-numeric it is considered not finite.
Integer and consequently strings and chars are always finite.
[y] = isfloat(x)
isfloat(x) returns 1 if x is a floating point array
or scalar, and 0 otherwise. Notice the difference between
isfloat and isreal. isreal(x) is 1 for integer objects,
while isfloat(x) is 0.
See also:
isreal
,
isint
,
iscomplex
.
[y] = isfunction(x)
isfunction(x) returns 1 if x is a function
(Tela-function, C-tela function or intrinsic function)
and 0 otherwise.
See also:
isCfunction
,
isTfunction
.
[y] = isint(x)
isint(x) returns 1 if x is integer scalar or array
and 0 if it is not.
See also:
isreal
,
isfloat
,
iscomplex
.
[y] = ismatrix(x)
ismatrix(x) returns 1 if x is a matrix (2D array)
and 0 if it is not.
See also:
isscalar
,
isvector
,
isarray
.
[y] = isreal(x)
isreal(x) returns 1 if x is numerical non-complex
array or scalar, and 0 otherwise.
See also:
isfloat
,
isint
,
iscomplex
.
[y] = isscalar(x)
isscalar(x) returns 1 if x is scalar and 0 if it is not.
See also:
isvector
,
ismatrix
,
isarray
.
[y] = isstr(x)
isstr(x) returns 1 if x is a character or string
and 0 otherwise.
See also:
isstring
,
ischar
.
NOTICE: Usually you want to use isstr, not isstring.
[y] = isstring(x)
isstring(x) returns 1 if x is a string and 0 otherwise.
See also:
ischar
,
isstr
.
NOTICE: Usually you want to use isstr, not isstring.
[y] = isundefined(x)
isundefined(x) returns 1 if x is not undefined and 0 if
it is undefined. Optional function arguments are undefined
if not assigned by the caller; isdefined can be used
inside the function to test whether this is the case.
See also:
isdefined
.
[y] = isvector(x)
isvector(x) returns 1 if x is a vector and 0 if it is not.
See also:
isscalar
,
ismatrix
,
isarray
.
[y] = isvoid(x)
isvoid(x) returns 1 if x is a void value and 0 otherwise.
[L] = length(x)
length(x) returns the total number of elements in array x.
If x is scalar, length(x) is 1.
See also:
size
,
rank
.
[y] = log(x)
y = log(x) computes the natural logarithm of x.
If x is complex, the result is complex. If x is real or
integer, but negative, the result is complex (purely
imaginary). If x is real or integer and non-negative,
the result is real.
If x is an array, the operation is applied componentwise.
If some of the components are negative, all components
of the result are complex.
[result] = menu(title...)
choice = menu("title","choice1","choice2",...) displays
a menu of choices and returns the number entered by
the user.
See also:
smenu
.
Error codes:
-1: Less than two input args
[y] = ones(...)
ones(n,m...) returns an integer array with all elements
equal to 1 of size n x m x ... .
ones(V) where V is an integer vector, and thus
ones(size(A)) work also.
See also:
rand
,
eye
.
Error codes:
-1: Input argument not an integer or IntVector
-2: Rank of requested tensor array exceeds MAXRANK
-3: Non-positive input argument
-4: Negative input argument
-5: Integer array rank not 1
[] = pause()
pause() will wait for a keypress on keyboard.
[y] = prod(x)
y = prod(x) multiplies all the elements of x, is x is an array.
If x is scalar, it is returned as such.
See also:
sum
.
Error codes:
-1: Nonnumeric input arg
[] = quit()
quit() stops Tela. quit() is synonym for exit().
[x] = rand(...)
rand() returns a random real x, 0<=x<1.
rand(N) (N positive integer) returns a real random vector of length N.
rand(N,M) returns a random matrix, and so on.
Error codes:
-1: Tried to create too high rank array
-2: Argument not an integer
-3: Non-positive integer argument
[y] = rank(x)
rank(A) returns the number of dimensions of array A.
The rank of a scalar is 0.
See also:
length
,
size
.
[B] = reshape(A...)
reshape(A,n,m,...) returns the data in array A rearranged
to have dimensionality n x m x ... . The product of the indices
must equal the length of A.
reshape(A,#(n,m...)) works also.
Error codes:
-1: First argument not an array
-2: Later argument not an integer
-3: Product of dimensions does not equal the length of first argument
-4: Number of input arguments exceeds MAXRANK
-5: Second arg is array but not integer vector
[y] = round(x)
round(x) returns the nearest integer.
x must be integer or real scalar or array. If it is an array,
the operation is applied componentwise.
See also:
floor
,
ceil
.
Error codes:
-1: Complex or nonnumeric input argument
[y] = sec(x)
y = sec(x) is the secant function
sec(x) = 1/cos(x).
[s] = sformat(formatstr...)
sformat("format-string",arg1,arg2,...) is similar to format,
except that it does not output to stdout but returns a string
variable.
See also:
format
.
Error codes:
-1: First argument not a string or char
[] = showcompiled(filename...)
showcompiled("filename.ct",f1,f2,...) compiles functions
f1,f2,... to C-tela code, creating "filename.ct".
If no suffix is given in "filename", the suffix
".ct" will be assumed.
showcompiled(f1,f2,...) displays on standard output.
See also:
t2ct
.
NOTE: STILL UNDER DEVELOPMENT
Error codes:
1: One of the args is not a Tela-function
2: Cannot open output file
[y] = sign(x)
y = sign(x) returns 1 if x>0, 0 if x==0, and -1 if x<0.
x must be real. If x is array, the operation is applied componentwise.
See also:
HeavisideTheta
.
Error codes:
-1: Complex or nonnumeric input argument
[y] = sin(x)
y = sin(x) computes the sine function of x.
If x is complex, the result is complex, otherwise real.
The argument must be in radians.
If x is an array, the operation is applied componentwise.
[y] = sinh(x)
y = sinh(x) computes the hyperbolic sine function of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
[...] = size(x)
[n,m,...] = size(A) finds out the dimensions of array A.
The number of n,m... must not exceed rank(A). If rank(A)==0
(that is, A is scalar), n=size(A) sets 1 to n.
V = size(A) assigns the dimension vector [n,m,..] to V.
If A is scalar, V is set to 1, if A is vector, V becomes
a one-element vector.
See also:
length
,
rank
.
Error codes:
-1: No output arguments
1: More than one output arg but non-array input arg
2: Too many output args relative to input arg rank
[result] = smenu(title...)
choice = smenu("title","choice1","choice2",...) displays
a menu of choices and returns the "choice" string corresponding
to the number entered by the user.
See also:
menu
.
Error codes:
-1: Less than two input args
[y] = sort(;x)
sort(x) returns array x sorted in ascending order.
If x is not an array, it is returned as is.
x = sort() sorts x in place.
x may not be complex.
Error codes:
1: Complex input arg
[] = source(fn)
source("file.t") loads the tela code from given file.
See also:
autosource
,
load
.
Error codes:
1: Operation did not succeed
2: Argument not a string
[y] = sqrt(x)
y = sqrt(x) computes the square root of x.
If x is complex, the result is complex. If x is real or
integer, but negative, the result is complex (purely
imaginary). If x is real or integer and non-negative,
the result is real.
If x is an array, the operation is applied componentwise.
If some of the components are negative, all components
of the result are complex.
[y] = str2num(s)
str2num(s) converts a string to a number.
The string must represent a scalar. If an error
occurs, str2num returns a void value.
Error codes:
1: Argument not a string or char
[y] = streq(s1,s2)
streq("string1","string2") returns 1 if the argument
strings are exactly equal and 0 otherwise. If one of
the args is not a string, the result is also 0.
See also:
strstarteq
.
[y] = strstarteq(s1,s2)
strstarteq("string1","string2") returns 1 if the argument
strings are equal on the first min(length(s1),length(s2))
characters and 0 otherwise.
If one of the the args is not a string, the result is also 0.
See also:
streq
.
[y] = sum(x)
y = sum(x) sums all the elements of x, is x is an array.
If x is scalar, it is returned as such.
See also:
prod
.
Error codes:
-1: Nonnumeric input arg
[] = system(s)
system("string") executes string as an external operating system
(Unix) command.
Error codes:
1: Argument not a string or char
[] = t2ct(fn)
t2ct("filename.t") translates t-code to ct-code.
Error codes:
1: Operation did not succeed
2: Argument not a string
3: Could not open output file
[y] = tan(x)
y = tan(x) computes the tangent function of x.
If x is complex, the result is complex, otherwise real.
The argument must be in radians.
If x is an array, the operation is applied componentwise.
[y] = tanh(x)
y = tanh(x) computes the hyperbolic tangent function of x.
If x is complex, the result is complex, otherwise real.
If x is an array, the operation is applied componentwise.
[] = tic()
tic() marks the CPU time at which it was invoked.
To measure CPU time, use tic() and toc().
See also:
cputime
,
toc
.
Example:
a = rand(100,100); tic(); b=inv(a); toc()
This would measure the CPU time in inverting a 100x100
random real matrix. See also: toc.
[t] = toc()
toc() gives the CPU seconds used since the last call to tic().
See also:
tic
,
cputime
.
[y] = tostring(x)
tostring(x) converts an integer vector to a string.
Error codes:
-1: Argument not an integer vector
[B] = transpose(A; P)
B = transpose(A) returns a transpose of array A: B[i,j,k...l] = A[l...k,j,i].
B = transpose(A,P) where P is integer vector transposes the indices in the
permutation defined by P.
For example if A has rank 3, B = transpose(A,[2,1,3]) causes the assignment
B[j,i,k] = A[i,j,k] to be carried out. B = transpose(A) would in this case
correspond to B[k,j,i] = A[i,j,k].
You can abbreviate "transpose(A)" by "A.'".
See also:
herm
.
Error codes:
-1: Permutation argument not integer array
-2: Permutation argument of bad rank or size
-3: Permutation argument contains invalid integers
[] = verbose(x)
THE FUNCTION 'verbose' IS OBSOLETE. USE 'VerboseMode' INSTEAD.
Error codes:
1: Input argument not an integer
[] = whos()
whos() displays names of variables together with their
types.
Next Chapter, Previous Chapter
Table of contents of this chapter, General table of contents
Top of the document, Beginning of this Chapter