HyperMath

Queries

Queries

Previous topic Next topic Expand/collapse all hidden text  

Queries

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  
hmtoggle_plus1greyFind

Finds the non-zero entries of the argument and returns a vector of their indices.  For matrices, the indexing is done linearly in column major order.

i = Find(m)

m

A scalar, vector or matrix.

hmtoggle_plus1greyLength

Returns the length of the argument.  For vectors, it is the number of elements, and for a matrix, the number of rows.

l = Length(m)

m

A scalar, vector or matrix.

s = GetCmdInput(i)

Returns the i-th argument (as a string) supplied as part of the –input option during batch mode execution.

n = GetNumOfCmdInputs()

Returns the number of arguments supplied as part of the –input option during batch mode execution.

hmtoggle_plus1greyI = GetTableIndices(t, sorted)

Returns the numerical indices of a table, optionally sorted.  Keys (non-numeric indices) are ignored.

t

The subject table.

sorted

A Boolean indicating if the returned indices should be sorted.  The default is false (unsorted).

l

A table of all the numeric indices in the subject table.

> t = {}; t[1]=1; t[-2]=2; t[‘X’]=3; t[‘Y’]=4;

> I = GetTableIndices(t,true)

> print(I[1], I[2])

-2  1

hmtoggle_plus1greyK = GetTableKeys(t)

Returns the keys (non-numerical indices) of a table.  Keys may not be ordered in the sequence they were created.

t

The subject table.

K

A table of the keys in the subject table.

> t = {}; t[1]=1; t[-2]=2; t[‘X’]=3; t[‘Y’]=4;

> K = GetTableKeys(t)

> print(K[1], K[2])

Y  X

hmtoggle_plus1greySize

Get dimensions of a variable.

Syntax

r, c = Size(Var)

r = Size(Var, 'r')

r = Size(Var, 1)

c = Size(Var, 'c')

c = Size(Var, 2)

l = Size(Var, '*')

lm = Size(Var, 'm')

Argument

Name

Description

 

Var

An HML variable.

 

'r' or 1

Returns the row dimension.

 

'c' or 2

Returns the column dimension.

 

'*'

Returns the product of the row and column numbers.

 

'm'

Returns the size of the longest dimension of Var.  Equivalent to Max(Size(X)).

Example

Syntax

 

A = ones(3, 2);

r, c = Size(A);

print(r, c);

r = Size(A, 'r');

print(r);

r = Size(A, 1);

print(r);

c = Size(A, 'c');

print(c);

c = Size(A, 2);

print(c);

l = Size(A, '*');

print(l);

lm = Size(A, 'm');

print(lm);  

See Also:

Length

hmtoggle_plus1greySubrange

Finds the first interval of points starting at a specified location within a vector that falls between a given band.  If none is found, an empty matrix is returned.

I = Subrange(v,low,up [,start] [,end])

v

A vector or matrix of data. For matrix the search is done in column-wise direction.

low

A scalar specifying the lower limit of the band.

up

A scalar specifying the upper limit of the band.  Must be greater than the lower limit.

start (optional)

A non-negative integer specifying the starting index of search in the vector.

end (optional)

A non-negative integer specifying the ending index of search in the vector. Must be greater than starting index.

l

A vector of all the indices in the interval. Empty if interval not found.

> v = [0,1,2,3,4,6,1,2,3,4];

> print(Subrange(v,2,5));        // Finds the first intervals of points between 2 & 5

[Matrix] 1 x 3

            3      4        5> print(Subrange(v,2,5,6));        // Finds the above again starting from index 6

 

[Matrix] 1 x 3

            8      9        10

See Also:

Checks