Chapter 13: Best practices Up Main page Chapter 15: Functional image processing in Quasar 

14 Built-in function quick reference

Some built-in functions are listed in Table 14.1↓. More runtime library functions are given in Table 14.2↓. For a detailed explanation of the functions, we refer to the Documentation Browser (F1 in Redshift).
Table 14.1 Common built-in functions (most functions are self-explanatory). Functions with asterisk (*) are accessible from __kernel__ and __device__ functions.
abs (*) absolute value/modulus sum (*) sum of the elements
acos (*) cumsum cumulative sum
atan (*) prod product of the elements
atan2 (*) cumprod cumulative product
ceil (*) mean
round (*) linspace
cos (*) lerp (*) linear interpolation
sin (*) dotprod (*) vector dot product
exp (*) zeros (*)
exp2 (*) power of two ones (*)
floor (*) rand uniformly distributed
mod (*) modulo randn normal distributed
frac (*) fractional part cell cell matrix
log (*) eye identity matrix
log2 (*) logarithm base 2 size (*) dimensions of object
log10 (*) logarithm base 10 numel (*) number of elements =prod(size(x))
max (*) complex (*) complex value
min (*) real (*) real part
saturate (*) clamps to [0,1] imag (*) imaginary part
sign (*) sign of the number float (*) conversion to float (kernel function)
sqrt (*) int (*) take integer part
tan (*) isnan (*) value is NaN (not a number)
angle (*) angle of a complex number isinf (*) value is infinite
transpose matrix transpose isfinite (*) value is finite
herm_transpose Hermitian transpose maxvalue (*) maximum value for the specified type
conj (*) conjugate minvalue (*) minimum value for the specified type
copy performs a shallow copy repmat repeat matrix
deepcopy performs a deep copy reshape reshape matrix
squeeze removes singleton dimensions shuffledims swaps dimensions
fft1 / ifft1 1-dimensional (I)FFT type returns data type of object
fft2 / ifft2 2-dimensional (I)FFT object creates an empty structure
fft3 / ifft3 3-dimensional (I)FFT sprintf build a C-style format string
shared (*) allocation of shared mem. printf print a C-style format string
shared_zeros (*) shared mem with zero init. strcat string concatenation
and (*) bitwise AND sscanf parses using a C-style format string
or (*) bitwise OR factorial the factorial function
xor (*) bitwise XOR inv matrix inverse
shl (*) bitwise left shift svd singular value decomposition
shr (*) bitwise right shift serial_do serial execution
not (*) bitwise inversion parallel_do parallel execution
mirror_ext (*) mirroring extension max_block_size see Subsection 2.4.4↑
periodize (*) periodic extension assert runtime assertion
tounicode converts vec to a UNICODE string schedule manual run-time scheduling function
toascii converts vec to an ASCII string mat2cell converts from matrix to cell matrix
fromunicode converts UNICODE string to vec cell2mat converts from cell matrix to matrix
fromascii converts ASCII string to vec
ind2pos converts linear index to n-D coords
imread reads an image img=imread("filename.png")
imwrite writes an image imwrite("filename.png", data)
imwrite("filename.png", data, [minval,maxval])
imshow shows an image imshow(img)
imshow(img, [minval,maxval])
eval Quasar expression evaluation y=eval("x->2*cos(x)")
save Save variables to file save("out.dat",A,B,C)
load Load variables from file [A,B,C]=load("out.dat")
dir Lists files in a directory files=dir("/home/*.png")
tic start timer tic()
toc stop timer and print elapsed time toc()
fopen opens file for reading/writing f=fopen("out.dat","wb")
fread reads from a file data=fread(f,[24,8],"float32")
fwrite writes to a file fwrite(f,data,"float32")
fclose closes a file fclose(f)
fgets reads one line in text modus from a file y=fgets(f)
plot generates a plot plot(x,y)
title set title of the plot title("text")
xlim sets ranges for the x-axis xlim([0, 10])
ylim sets ranges for the y-axis ylim([-pi, pi])
xlabel sets the x-axis label xlabel("x")
ylabel sets the y-axis label ylabel("y")
legend displays a legend legend("serie 1", "serie 2")
disp display a matrix disp(A)
print print text to the console print A,...
error generate an error error A,...
pause pauses program execution for n msec. pause(0.5)
Table 14.2 Runtime library functions.


 Chapter 13: Best practices Up Main page Chapter 15: Functional image processing in Quasar