Vector/Matrix Routines

The following is a list of the currently included vector/matrix routines. Most of them are from the Meschach Library v1.2b. Some more NMR specific routines have been added. The third field of each description lists the input and output objects that must be provided when calling the routines through the Tcl wrappers provided in NMRView. The letters stand for various types of objects that can be used:

W
An Integer Vector.
V
A Double-Precision Real Vector.
Z
A Double-Precision Complex Vector.
P
A Permutation.
Lower case letters refer to objects that are returned by the routines. Here is an example of the Tcl commands one would type to create to vectors, containing random numbers, and add them together. To create two real vectors,each 32 elements long:

v_get a 32
v_get b 32

By default the elements are set to the value 0.0. We can set them to random numbers:

v_rand a
v_rand b
Then add the two vectors together and put the result in a new vector c:
v_add a b c
 
iv_add w WWw Add integer vectors
m_add m MMm Add matrices
zm_add n NNn Add complex matrices
v_add v VVv Add vectors
zv_add z ZZz Add complex vectors
get_col v MIv Extract a column from a matrix
set_col m MIV Set the column of a matrix to a given vector
px_cols m PMm Permute the columns of a matrix
swap_cols m MIIII 
zswap_cols n NIIII 
bd_copy b Bb 
iv_copy w Ww Copy integer vector
px_copy p Pp Copy permutation
v_copy v Vv Copy vector
zv_copy z Zz Copy complex vector
m_copy m Mm Copy dense matrix
iv_finput w Fw Input integer vector from a stream
m_finput m Fm Input matrix from a stream
zm_finput n Fn Input complex matrix from stream
px_finput p Fp Input permutation from a stream
v_finput v Fv Input vector from a stream
zv_finput z Fz Input complex vector from a stream
m_foutput 0 FM Output matrix to a stream
m_output 0 M Output matrix to stdout (macro)
px_foutput 0 FP Output permutation to a stream
px_output 0 P Output permutation to  stdout (macro)
v_foutput 0 FV Output vector to a stream
zv_foutput 0 FZ 
v_output 0 V Output vector to  stdout (macro)
zv_output 0 Z 
iv_foutput 0 FW Output integer vector to a stream
iv_output 0 W Output integer vector to  stdout (macro)
bd_get b III Allocate and initialise band matrix
iv_get w I Allocate and initialise an integer vector
m_get m II Allocate and initialise a matrix
px_get p I Allocate and initialise a permutation
v_get v I Allocate and initialise a vector
zv_get z I Allocate complex vector
m_ident m M Sets matrix to identity matrix
px_ident p P Sets permutation to identity
px_inv p Pp Invert permutation
v_max d Vi Computes max vector entry and index
v_min d Vi Computes min vector entry and index
m_mlt m MMm Multiplies matrices
zm_mlt n NNn Multiply complex matrices
mmtr_mlt m MMm Computes  AB^T
mtrm_mlt m MMm Computes  A^TB
mv_mlt v MVv Computes  Ax
zmv_mlt z NZz Complex matrix-vector multiply
px_mlt p PPp Multiply permutations
sm_mlt m DMm Scalar-matrix multiplication
zsm_mlt n CNn Complex scalar-matrix product
sv_mlt v DVv Scalar-vector multiply
zv_mlt z CZz Complex scalar-vector product
vm_mlt v MVv Computes  x^TA
zvm_mlt z NZz Computes  A^*x  (complex)
mv_mltadd v VVMDv Computes  y <- Ax+y
v_mltadd v VVDv Computes  y <- alpha*x+y  for vectors  x ,  y
zv_mltadd z ZZCz Complex scalar-vector multiply and add
vm_mltadd v VVMDv Computes  y^T <- y^T+x^TA
iv_move w WIIwI 
m_move m MIIIImII 
mv_move v MIIIIvI 
v_move v VIIvI 
zv_move z ZIIzI 
vm_move m VImIIII 
m_norm1 d M Computes  ||A||_1  of a matrix
v_norm1 d V Computes  ||x||_1  for a vector
v_norm2 d V Computes  ||x||_2  (the Euclidean norm) of a vector
m_norm_frob d M Computes the Frobenius norm of a matrix
m_norm_inf d M Computes  ||A||_inf  of a matrix
v_norm_inf d V Computes  ||x||_inf  for a vector
m_ones m M Set matrix to all 1's
v_ones v V Set vector to all 1's
in_prod d VV Inner product of vectors
m_rand m M Randomise entries of a matrix
v_rand v V Randomise entries of a vector
zv_rand z Z Randomise complex vector
bd_resize b bIII Resize band matrix
iv_resize w wI Resize an integer vector
m_resize m mII Resize matrix
px_resize p pI Resize a permutation
v_resize v vI Resize a vector
zv_resize z zI Resize complex vector
get_row v MIv Extract a row from a matrix
set_row m MIV Set the row of a matrix to a given vector
swap_rows m MIIII 
zswap_rows n NIIII 
px_sign i P Returns the sign of the permutation
v_slash v VVv Computes componentwise ratio of vectors
iv_sort w Wp 
v_sort v VP Sorts vector components
v_star v VVv Componentwise vector product
iv_sub w WWw Subtract integer vectors
m_sub m MMm Subtract matrices
zm_sub n NNn Subtract complex matrices
v_sub v VVv Subtract two vectors
zv_sub z ZZz Subtract complex vectors
v_sum d V Sum of components of a vector
bd_transp b Bb Transpose band matrix
m_transp m Mm Transpose matrix
px_transp p PII Transpose a pair of entries
px_vec v PVv Computes  Px  where  P  is a permutation matrix
pxinv_vec v PVv Computes  P^Tx  where  P  is a permutation matrix
sub_vec v VIIv 
iv_zero w W 
m_zero m M Zero a matrix
v_zero v V Zero a vector
ft z Z 
ift z Z 
hft z V 
phase z ZDD 
v_cmplx z V 
zv_real v Z 
zv_imag v Z 
zv_power v Z 
v_interp v V 
apsb d ZIII 
v_setrng v VDII 
v_dc v VD 
v_sine v VDDDD 
v_expd v VDD 
v_rev v V 
LUfactor m MP Compute  LU  factors with implicit scaled partial pivoting
LUsolve v MPVv Solve  Ax=b  using  LU  factors
svd v MMMv Compute the SVD of a matrix
v_setval 0 VID 
v_getval d VI 
iv_setval 0 WII 
iv_getval i WI 
m_setval 0 MIID 
vz_mlt z VZz 
zv_gen z VIz 
v_abc v VD 
v_peaks v VDv 
v_cum v Vv 
zv_cphs v Zv 
zv_max d Zi 
zv_min d Zi 
NvZVecAmp v Zv