Quasar > General

General

system.q

The system library for Quasar: contains functions that are not built-in, but that are very often used.
If the function you are looking for, cannot be found in system.q (or any of the other .q files located in the Library directory), please feel free to implement this function, and send a copy of the code to bart.goossens@telin.ugent.be. This way, I can make sure that the function is distributed automatically in later versions of Quasar.

See system.q


An overview of the different functions and classes:

allreturns 1 if all elements of x are non-zero, otherwise 0.
anyreturns 1 if at least one element of x is non-zero, otherwise 0.
apply_fnApplies a mapping function onto the input data.
apply_mapApplies a mapping function onto the input data.
binsearch1dA 1D binary search algorithm: given a sorted vector x0, find the index of the element that is closest to 'value'.
catHorizontal concatenation function: works for matrix, complex matrices and cell matrices
circshift (1)Applies circular (periodic) shifting of a given vector, according to the relationship y[p] = x[p+d]
circshift (2)Applies circular (periodic) shifting of a given matrix, according to the relationship y[p] = x[p+d]
circshift (3)Applies circular (periodic) shifting of a given cube, according to the relationship y[p] = x[p+d]
circshift (4)Applies circular (periodic) shifting of a given complex-valued vector, according to the relationship y[p] = x[p+d]
circshift (5)Applies circular (periodic) shifting of a given complex-valued matrix, according to the relationship y[p] = x[p+d]
circshift (6)Applies circular (periodic) shifting of a given complex-valued cube, according to the relationship y[p] = x[p+d]
delinearize_indexDe-linearizes an index (converts from a 1D index to a higher- dimensional index) given the size of the matrix. Note: only up to three dimensions are currently supported
diag (1)Creates a diagonal matrix from a one dimensional vector. The non-diagonal elements are set to zero.
diag (2)Creates a diagonal matrix from a one dimension
diag (3)Extracts the diagonal elements of a square real-valued matrix
diag (4)Extracts the diagonal elements of a square complex-valued matrix
distinctSelects all distinct values in a given vector/matrix/cube
distinct_mapSelects all distinct values in a given vector/matrix/cube + the mapping function of the original set onto y. This function is useful for e.g. connected components algorithms for performing label normalization. The connected component algorithm may output labels in the range [0,MN-1], where MN are the dimensions of the image. With this function, each integer in the range 0..K-1 will correspond to a unique label (where K is the total number of labels)
dotprodComputes the dot product between two vectors
fftshift1Moves the DC components of a 1D discrete Fourier transform (DFT) to the center of the data. For higher dimensional data - it is presumed that the FFT data is stored in the last dimension
fftshift2Moves the DC components of a 2D discrete Fourier transform (DFT) to the center of the data
fftshift3Moves the DC components of a 3D discrete Fourier transform (DFT) to the center of the data.
findFinds the location of the non-zero elements of x. The result is a list of positions [[x0, y0, z0], [x1, y1, z1], ...].
find_index_maxfinds the index of the FIRST occuring maximal value of the given cube. The cube is traversed in zigzag order (as in raster scanning).
find_indices_nonzerofinds the indices of all non-zero values of the given cube.
findstringFinds all occurences of the specified substring within a string. Returns a vector with the indices of the occurences.
fliplrflips a two dimensional matrix horizontally
flipupflips a two dimensional matrix upside-down (vertically)
herm_transposeHermitian transpose of a matrix
ifftshift1The inverse operation of fftshift1
ifftshift2The inverse operation of fftshift2
ifftshift3The inverse operation of fftshift3
indexofReturns the index of the first occurence of a character within a string
interp1Performs one-dimensional interpolation
interp1_functionGet a device function that can be used for one-dimensional interpolation
interp2Performs two-dimensional interpolation
interp2_functionGet a device function that can be used for two-dimensional interpolation
invert_functionComputes the inverse of a function
iscellreturns 1 if x is a cell matrix, 0 otherwise
iscomplexreturns 1 if x is complex-valued, 0 otherwise
iscubereturns 1 if x is a cube (max. dimensionality 3), 0 otherwise
isemptyreturns 1 if the number of elements of x is 0 and 0 otherwise.
isfunctionreturns 1 if x is a function, 0 otherwise
iskernelreturns 1 if x is a kernel function, 0 otherwise
ismatrixreturns 1 if x is a matrix (max. dimensionality 2), 0 otherwise
isobjectreturns 1 if x is an object, 0 otherwise
isrealreturns 1 if x is real-valued, 0 otherwise
isscalarreturns 1 if x is scalar, 0 otherwise
isstringreturns 1 if x is a string, 0 otherwise
isvectorreturns 1 if x is a vector (max. dimensionality 1), 0 otherwise
joinFunction: vec[string].join
kronComputes the Kronecker product of two multi-dimensional matrices
lastindexofReturns the index of the last occurence of a character within a string
lerpperforms linear interpolation between a and b (with weight d)
medianComputes the median along the rows of a given matrix.
meshgrid (1)Generate matrices with coordinates for a 2D Cartesian grid
meshgrid (2)Generate matrices with coordinates for a 3D Cartesian grid
nanmaxCalculates the maximum of all matrix elements in x, after removing all NaN values.
nanmeanCalculates the mean of all matrix elements in x, after removing all NaN values.
nanminCalculates the minimum of all matrix elements in x, after removing all NaN values.
ndimsreturns the number of dimensions of x
nextpow2returns the next integer power of two
num2strconverts a number to string
object (1)The base class for all objects in Quasar
prevpow2returns the previous integer power of two
qdummyThe base class for all objects in Quasar
qradiomenugroupThe base class for all objects in Quasar
qscenelightRepresents an OpenGL light - for lighting effects in the scene
replaceReplaces all occurences of a substring within a string by a replacement stringh
replace_by_indexReplaces values of the data cube by a certain value, but only at the specified indices.
replace_maskInterpolates between two input data cubes based on a given mask (with values between 0 - 1). This function can be used for alpha matting as well.
reverseReturns a string in which the order of the characters is reversed
selectSelects all values with the specified filter.
select_thresholdSelects all values that are larger than a given threshold useful for implementing 'logical' indexing, e.g. in Matlab: x(x > T).
sortinplace sort along the rows (currently: ascending sort). Internally uses a parallel bitonic sorting algorithm (with complexity O(N)^2 * N / T, where T is the number of parallel threads).
sort2a non-inplace sort along the rows that also returns the indices (ascending sort) Internally uses a parallel bitonic sorting algorithm (with complexity O(N)^2 * N / T, where T is the number of parallel threads).
splitSplits a string according to the specified delimiter. The delimiter may contain one or multiple characters. In case of multiple characters, the function considers the delimiter to be a substring. For example "1, 2".split(", ") returns {"1","2"}
stdcomputes the standard deviation of all elements in a matrix
str2numconverts the string to a numerical value
substrReturns a part of the string
swapSwaps the values of two variables
system.qThe system library for Quasar: contains functions that are not built-in, but that are very often used.
tolowerConverts the specified string to lower case
toupperConverts the specified string to upper case
trimTrims the specified characters (usually whitespace) from the input string, both on the left side as well as on the right side.
vertcatVertical concatenation function: works for matrix, complex matrices and cell matrices