HyperMath

Checks

Checks

Previous topic Next topic Expand/collapse all hidden text  

Checks

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

Checks if all elements of the argument are non-zero.  For scalars and vectors, it returns a 1 if all elements are non-zero, else a 0.  For matrices, it works on each column and treats each as a separate vector.  The return is a row vector of 1 and 0 corresponding to each column.

b = All(m)

m

A scalar, vector or matrix.

> M = [1,2,3;4,5,0]; // The last column has a zero

> print(All(M))

[Matrix] (1 x 3)

1 1 0

hmtoggle_plus1greyAny

Checks if any elements of the argument are non-zero.  For scalars and vectors, it returns a 1 if any element is non-zero, else a 0.  For matrices, it works on each column and treats each as a separate vector.  The return is a row vector of 1 and 0 corresponding to each column.

b = Any(m)

m

A scalar, vector or matrix.

> M = [0,0,0;0,0,1]; // The last column has a one

> print(Any(M))

[Matrix] (1 x 3)

0 0 1

hmtoggle_plus1greyIsEmpty

Checks if argument has any content.  Returns a logical true if empty, else a logical false.

b = IsEmpty(m)

m

A scalar, vector or matrix.

hmtoggle_plus1greyIsEqual

Checks for equality among the two inputs for content, dimension and size.  Returns a logical true if all are equal, else a logical false.

b = IsEqual(m1,m2)

m1,m2

Scalars, vectors or matrices.

hmtoggle_plus1greyisfinite

Checks if input elements are finite or not.

R = isfinite(M)

M

A matrix or a scalar, real or complex.

R

A matrix of ones or zeros, depending if the elements of M are finite values or not.

 

x = NaN;

print('x = ', x);

print('isfinite(x) = ', isfinite(x));

y = Inf;

print('y = ', y);

print('isfinite(x) = ', isfinite(y));

M = [1-i, NaN; Inf, 3]

print('M = ', M);

print('isfinite(M) = ', isfinite(M));

a = [-2.5 -1.5 0; 1.2 2.3 2i];

A = 1./a;

B = 0./a;

print('A = ', A)

print('B = ', B)

print('isfinite(A) = ', isfinite(A))

print('isfinite(B) = ', isfinite(B))

Comments

isfinite returns 1 for a complex number only if both the real and imaginary parts are finite values.

hmtoggle_plus1greyIsInf

Checks each entry for +/- Inf and returns a Boolean for each.  For scalar inputs, the return is a one element vector.  A complex number is Inf if either part is Inf.

b = IsInf(m)

m

A scalar, vector or matrix.

> print(IsInf([1/0, 0/0]))

[Matrix] (1 x 2)

1 0

hmtoggle_plus1greyIsNaN

Checks each entry for NaN and returns a Boolean for each.  For scalar inputs, the return is a one-element vector.  A complex number is NaN if either part is NaN.

b = IsNaN(m)

m

A scalar, vector or matrix.

> print(IsNaN([1/0, 0/0]))

[Matrix] (1 x 2)

0 1

hmtoggle_plus1greyIsNegInf

Checks each entry for negative Inf returns a Boolean for each. For scalar inputs the return is a one element vector. A complex number is -Inf if either part is -Inf.

b = IsNegInf(m)

m

A scalar, vector or matrix.

> print(IsNegInf([-1/0, 0/0]))

[Matrix] (1 x 2)

1 0

hmtoggle_plus1greyIsNumeric

Checks if argument contents are numeric.  Returns a logical true if all contents are numeric, else a logical false.

b = IsNumeric(m)

m

A scalar, vector or matrix.

hmtoggle_plus1greyIsScalar

Checks if argument is a scalar.  Returns a logical true if a scalar, else a logical false.

b = IsScalar(m)

m

A scalar, vector or matrix.

hmtoggle_plus1greyIsVector

Checks if argument is a vector, that is 1xN or Nx1. Returns a logical true if  N is greater than 1, else a logical false.

b = IsVector(m)

m

A scalar, vector or matrix.

See Also:

Queries