4.5 Math commands

 

There are the commands to use the AMMP math routines. The commands support the VAR type that combines the possibility to use variable names and float/integer constant. You must remember that 1 and 1.0 constants don't have the same meaning: the first one is an integer constant and the second one is a floating point constant.

 

 

ADD   (VAR)Var1   (VAR)Var2
 

Arithmetic sum between two terms.

Parameters:
Var1    First addendum. If it's a variable name, the result is stored in it.
Var2   Second addendum.

Return message:
Result of the arithmetic operation.

 

Example:
ADD    a   1;

 

See also:
DIV, MUL, SUB.


COS   (VAR)Var
 

Cosine trigonometric function.

Parameters:
Var    Angle in radians.

Return message:
Result of the trigonometric function.

 

Example:
COS    0.5;

 

See also:
SIN, TAN.


DIV   (VAR)Var1   (VAR)Var2
 

Arithmetic division between two terms.

Parameters:
Var1    Dividend. If it's a variable name, the result (quotient) is stored in it.
Var2   Divisor.

Return message:
Result of the arithmetic operation.

 

Example:
DIV    1.0   3.0;

 

See also:
ADD, MUL, SUB.


FIX   (VAR)Var
 

Round down to an integer.

Parameters:
Var    Dividend. If it's a variable name, the result is stored in it.

Return message:
Result of the arithmetic operation.

 

Example:
FIX    1.5;

 

See also:
None.


INDEX   (VAR)Var   (UINT)AtmNum
 

Get the serial number of the specified atom number.

Parameters:
Var    Variable name in which the serial number is stored.
AtmNum    Atom number.

Return message:
Serial number.

 

Example:
INDEX    n   10;

 

See also:
SERIAL.


LINMIN   (VAR)Var
 

Search the atom direction for a minimum.

Parameters:
Var    The variable name in which the result is stored..

Return message:
The number of steps to reach the minimum.

 

Example:
LINMIN   a;

 

See also:
None.


MAX   (VAR)Var1   (VAR)Var2
 

Find the maximum of two values.

Parameters:
Var1    First term. If it's a variable name, the result is stored in it.
Var2   Second term.

Return message:
The maximum value.

 

Example:
MAX   a   11.3;

 

See also:
MIN.

 


MIN   (VAR)Var1   (VAR)Var2
 

Find the minimum of two values.

Parameters:
Var1    First term. If it's a variable name, the result is stored in it.
Var2   Second term.

Return message:
The minimum value.

 

Example:
MIN   2.0   11.3;

 

See also:
MAX.


MOV   (VAR)Var1   (VAR)Var2
 

Set a variable to another one.

Parameters:
Var1    Destination variable.
Var2   Source variable.

Return message:
Result of the operation.

 

Example:
MOV   a   b;

 

See also:
NOP,
SETF, SETI.


MUL   (VAR)Var1   (VAR)Var2
 

Arithmetic multiplication between two terms.

Parameters:
Var1    Multiplicand. If it's a variable name, the result is stored in it.
Var2   Multiplier.

Return message:
Result of the arithmetic operation.

 

Example:
MUL   a   3.0;

 

See also:
ADD, DIV, SUB.


NOP   (VAR)Var
 

Dump the value of a variable. To know the names of the system variables, click here.

Parameters:
Var    Variable name. If it's undefined, the null value is returned.

Return message:
The variable value.

 

Example:
NOP   a;

 

See also:
MOV,
SETF, SETI.


RANDF   (VAR)Var
 

Generate a pseudo-random floating point number in the 0...1 range.

Parameters:
Var    Variable in which the result is stored.

Return message:
Floating point random number.

 

Example:
RANDF    a;

 

See also:
None.


SERIAL   (VAR)Var   (CHAR)Res   (CHAR)Atom
 

Set a variable equal to the serial atom number given by the atom name.

Parameters:
Var    Variable name in which the serial number is stored.
Res    Residue number.
Atom   Atom name.

Return message:
Serial number.

 

Example:
SERIAL    n   100   ca;

 

See also:
INDEX.


SETF   (VAR)Var   (FLOAT)Val
 

Define a floating point number variable. All variables are cleared calling the RESET command.

Parameters:
Var    Variable name.
Val   Floating point value.

Return message:
None.

 

Example:
SETF   x   4.25;

 

See also:
NOP, MOV, SETI.


SETI   (VAR)Var   (INT)Val
 

Define an integer number variable. All variables are cleared calling the RESET command.

Parameters:
Var    Variable name.
Val   Integer value.

Return message:
None.

 

Example:
SETI   k   1;

 

See also:
NOP, MOV, SETF.


SIN   (VAR)Var
 

Sine trigonometric function.

Parameters:
Var    Angle in radians.

Return message:
Result of the trigonometric function.

 

Example:
SIN    pi;

 

See also:
COS, TAN.


SQRT   (VAR)Var
 

Perform the square root.

Parameters:
Var    Square root argument. If it's a variable name, the result is stored in it.

Return message:
Result of the arithmetic operation.

 

Example:
SQRT    2.0;

 

See also:
None.


SUB   (VAR)Var1   (VAR)Var2
 

Arithmetic subtraction between two terms.

Parameters:
Var1    Minuend. If it's a variable name, the result is stored in it.
Var2   Subtrahend.

Return message:
Result of the arithmetic operation.

 

Example:
SUB    a   2.42;

 

See also:
ADD,
DIV, MUL.


TAN   (VAR)Var
 

Tangent trigonometric function.

Parameters:
Var    Angle in radians.

Return message:
Result of the trigonometric function.

 

Example:
TAN    2.23;

 

See also:
COS, SIN.


TIME   (VAR)Var
 

Time for calculation speed measurement. In the Unix systems, it gives the number of seconds since the 00:00:00 UTC, January 1, 1970. In the Windows systems, it gives the number of seconds since the power on.

Parameters:
Var    It's the floating point variable name in which the time is stored.

Return message:
The current time in floating point format.

 

Example:
TIME    tm;

 

See also:
None.