Quasar > Built-in functions

Built-in functions


An overview of the different functions and classes:

$ftypeFunction: $ftype
$inlineFunction: $inline
assertAsserts that x is true, and generates an error otherwise (if x is false)
castCasts a value to a different type. This function should only be used in the context of generic methods.
cellCreates an empty cell vector/matrix
cell2matConverts a cell matrix to an ordinary matrix. All elements of the cell matrix must have the same data type
complex (1)Converts a real-valued number/matrix to a complex-valued number/matrix
complex (2)Returns a complex-valued number/matrix, based on the specified real/imaginary parts
copyReturns a one-level deep copy of the specified variable. This is useful for creating e.g. a temporary copy of a matrix that can be changed without affecting the original matrix. Note: to copy nested objects (such as cell matrices), it can be useful to use the function
cummax (1)Computes the cumulative maximum of all elements of a matrix (along the last non-singleton dimension)
cummax (2)Computes the cumulative maximum of all elements of a matrix along the specified dimension
cummin (1)Computes the cumulative minimum of all elements of a matrix (along the last non-singleton dimension)
cummin (2)Computes the cumulative minimum of all elements of a matrix along the specified dimension
cumprod (1)Computes the cumulative product of all elements of a matrix (along the last non-singleton dimension)
cumprod (2)Computes the cumulative product of all elements of a matrix along the specified dimension
cumsum (1)Computes the cumulative sum of all elements of a matrix along the last dimension
cumsum (2)Computes the cumulative sum of all elements of a matrix along the specified dimension
cuninitCreates a *uninitialized* complex-valued data vector of length a
czerosCreates a *zero-initialized* complex-valued data vector or matrix
deepcopyPerforms a deep copy of the specified variable, including all the objects it refers to.
dotprod Computes the dot product between two vectors
errorGenerates an error with the specified message
evalDynamic expression evaluation
eyeCreates an n x n identity matrix
factorialReturns x!
fromasciiConverts a string to a vector that can be processed further using vector operations. This is done as follows: first, a vector is created with the same length as the string. Next, each character of the string is converted to an ASCII-value (0-127). Then the ASCII-values are written to the vector.
fromunicodeConverts a string to a vector that can be processed further using vector operations. This is done as follows: first, a vector is created with the same length as the string. Next, each character of the string is converted to a UNICODE-value (0-65535). Then the UNICODE-values are written to the vector.
has_displayIndicates whether a display is available for the current system. Typically, SSH connections without X11 port forwarding enabled do not support a display. In this case, all GUI function calls (`imshow()`, `form()`) etc. will fail. This function allows to detect this situation, allowing to provide an alternative code path when no display is available. This is particularly useful when running simulations on a remote system.
imagReturns the imaginary part of a complex number / matrix
ind2posConverts a linear index to a position vector of length N (for indexing an N-dimensional matrix of size `sz`). Here, `N = numdims(zeros(sz))`.
linspaceReturns a linearly spaced vector from a (inclusive) to b (inclusive), containing c elements.
logoutputAutomatically logs all output in the output window/console to the specified file. The function returns an object that the caller must keep. As soon as the object goes out of scope, the output file is closes. This function is particularly useful to save the output of simulation scripts, without having to revert to fopen()/fclose() functions.
mat2cellConverts a matrix to a cell matrix
maxComputes the maximum value of all elements x. The result is a scalar number.
maxdimComputes the maximum value of a matrix along a given dimension. The result is a matrix.
maxvalueReturns the maximum representable value for the specified data type
mean (1)Computes the mean value of all elements x.
mean (2)Computes the mean value of all elements x along dimension d.
minComputes the minimum value of all elements x. The result is a scalar number.
mindimComputes the minimum value of a given matrix along a given dimension. The result is a matrix.
minvalueReturns the minimum representable value for the specified data type
ndimsReturns the number of dimensions of x.
newDynamically constructs an object of the specified type
numelReturns the number of elements in x For matrices, numel(x) = prod(size(x))
object (2)Creates an empty untyped object, which can be used to store data.
onesCreates a *one-initialized* real-valued data vector/matrix
pauseDelays the program for "delay" milliseconds
pos2indConverts a position vector of length N to a linear index (for indexing an N-dimensional matrix of size `sz`). Here, `N = numdims(zeros(sz))`.
printPrints text to the console
prod (1)Computes the product of all elements of a matrix (along all dimensions)
prod (2)Computes the product of all elements of a matrix, along the specified dimension d=0,1,2
randCreates a uniformly distributed data vector/matrix (values are in the range [0,1[)
randnCreates a Gaussian distributed data vector/matrix, with mean=0 and standard deviation=1
realReturns the real part of a complex number / matrix
repmatRepeats the matrix 'dims' times.
reshapeChanges the dimensions of a matrix, by reordering the elements of the matrix. Note that Quasar uses a row-major ordering of the elements by default.
scheduleInvokes the run-time scheduler to take a decision (without executing the decision) This function is used internally by Quasar for multi-platform kernel functions, where every target platform requires a radically different implementation. Normally this function should not be called from user code.
sharedAllocates *uninitialized* shared memory according to the dimensions x.
shared_zerosAllocates *zero-initialized* shared memory according to the dimensions x. It is important to use the keyword 'syncthreads' because the zero- initialization operation is distributed along all threads. The 'syncthreads' keyword then ensures that all threads see a fully zero-initialized copy of y.
shuffledimsPerforms a permutation on the dimensions of a matrix
size (1)Returns a vector with the size of x
size (2)Returns the size of x along dimension y (y=0,1,2)
squeezeRemoves singleton dimensions from a matrix variable
strcatConcatenates strings
structCreates an empty untyped object, which can be used to store data. Note that this function is deprecated. Please use object() instead.
sum (1)Computes the sum of all elements of a matrix (along all dimensions)
sum (2)Computes the sum of all elements of a matrix, along the specified dimension d=0,1,2
ticSet a timer to be read by the next call to toc.
toasciiConverts a vector with ASCII values (0-127) to a string representation.
tocPrint and return the time elapsed since the last tic
tounicodeConverts a vector with UNICODE values (0-65535) to a string representation.
transposeTransposes a matrix.
type (1)Returns the type of an object
type (2)Checks whether the variable 'x' is of type 'y'
uninitCreates an *uninitialized* real-valued data vector/matrix
uninit_TFunction: uninit[T]
zerosCreates a *zero-initialized* real-valued data vector/matrix