Numerical Utilities  NumUtilGeneral Purpose Vector and Matrix Math UtilitiesVersion 1.2 The Numerical Utilities perform common mathematical operations on files containing lists of numbers. Files may represent vectors or matrices. The files may be plotted by various tools, such as XGRAPH, and the utilities may be considered a means to manipulate data to be plotted. The NumUtils are useful for anyone studying Digital Signal Processing (DSP), linear algebra, statistics, or numerical analysis in general, as well any field dealing with numerical data. The utilities form a simple and inexpensive alternative to, or can be used to complement, more extensive environments such as Octave, Matlab, or programming libraries such as LAPACK by leveraging the familiar capabilities of the operating system's commandline and/or script files. NumUtil enables filenames to be treated as variablenames.
List of NumUtils: Scaling / Shifting scale  Scales a real or complex vector file by a scalar. shift  Adds a scalar to a real or complex vector file. normalize  Normalize a vector. Makes sum (or max) of terms equal 1.0. Generating Functions sine_gen  Generates sinusoidal vectors. rand_gen  Generates random vectors, noise. enter_vec  Creates new vector or matrix by keyboard prompts/input. identity_matrix  Generates identity matrix. Conversions abs  Computes absolute value, or complex magnitude. cmag  Converts a complex vector file into real (magnitude) vector. db  Converts a real vector file from linear to deciBells (dB). phase  Converts a complex vector file into magnitude and phase. real2cmplx  Converts a real vector to a complex vector. extract_real  Extracts real part of complex vector to real vector. extract_imaginary  Extracts imaginary part of complex vector to real vector. barchart  Converts real vector to barchart graph. image2matrix  Convert an image file to a matrix file. mat2image  Convert matrix to an image file. num2vec  Converts simple number list to NumUtils Vector format. vec2nums  Converts real or complex vector files to simple number list files. Operations / Transforms add  Adds two real or complex vectors or matrices. sub  Subtracts one vector or matrix from another. conjg  Conjugates a complex vector. dotpr  Computes the dotproduct (innerproduct) of two vectors. cdotpr  Complexconjugate dotproduct of two complex vectors. matmul  Matrixmatrix or Matrixvector multiply, real or complex. multpbp  Multiplies real or complex vector by vector (point by point). outpr  Outerproduct multiply. Multiplies two vectors, produces matrix. zfill  zerofills a vector to arbitrary length. convolve  Convolves two complex or real vectors. (FIR filter) correlate  Computes the correlation of two complex or real vectors. fft  Computes FFT on a complex or real vector (of any length). window  Computes windowing functions, hamming, hanning, bartlet, blackman. transpose  Transposes real matrix, or conjugatetransposes complex matrices. ucirc  Produces Unit Circle points for Zplane plots. fft2D  Computes the 2DFFT on a complex or real matrix. eigen  Computes Eigen vectors and values. svd  Computes Singular Value Decomposition. z_trans  Ztransform, finds roots of arbitrary polynomials. matinvert  Invert a real or complex matrix. matXvec  Extract matrix row or column to a vector. mdeterm  Compute the matrix determinant, real or complex. augmatvec  Augment matrix by vector. Adds row or column to matrix. join2xy  Joins 2 Real Vectors into one Vector, becoming x and y. Useful for plotting one file against another. differentiate  Differentiates a real vector. integrate  Integrates a real vector. decimate  Decimates (subsamples) a real or complex vector. Statistics statistics  Computes mean, variance, min, max, and optionally the median, of a real vector. histogram  Plots the histogram of real vectors. TBD: convolve2d, more examples, tutorials, etc.. Any volunteers? Background: The NumUtil are provided as sourcecode, and are conveniently compiled on most any platform with a C compiler. The utilities are simple and selfcontained. No additional tools or libraries are needed. A simple Build.com script is provided to automatically compile the utilities, or to show the suggested compilation commands. Most of the NumUtil programs are under 100 lines of code. (grep ";" xx.c  wc) NumUtil is consistent with the convention of other file utilities, such as copy, diff, cat, sort, zip, grep, awk, xv, xgraph, latex, etc.. All data files are ASCII text files, (not binary) which are readable, printable, and convenient to produce, edit, or read with other programs. Being filebased utilities, data is not limited by memory (RAM size). Because each NumUtil tool is an independent utility, they can be called from programs without risk of library or symbol conflicts. (eg. system() call.) They can also be called directly from the commandline, interactively, without need of writing a program. Although many of the functions are trivial, the collection has value by virtue of it's consistency and completeness. NumUtil presently supports four formats for data files: (1) Real Vector, (2) Complex Vector, (3) Real Matrix, (4) Complex Matrix.A simple XMLlike convention in the datafile's first line indicates the file's type, and enables the tools to operate consistently on either kind of datafile. The header also specifies the file's dimension(s), as either vector or 2D matrix. See below for format specification. The utilities include extensive checking and are fully documented. The venerable NumUtil have been in use by several groups of researchers for more than a decade. We noticed others often reinventing common functions on projects without knowledge of the NumUtil, and realized they may be beneficial to share with others. Therefore, we hope these utilities and conventions will be helpful, and that contributors might combine efforts by adding additional functions and utilities consistent with the initial set, as well as to help in improving and enhancing them, or that it serves as the basis or template for other endeavors. NumUtil are released under GPL, included in gpl.txt. So that everyone may share in combined efforts, we request that improvements/comments be directed back to xgraphadmin@xgraph.org for centralized redistribution with credit.
Download: Click (or rightclick) Download NumUtil.tar.gz . Vers1.1 (44 KB)
Build/Install:
Try: source script_fft.com ( sine_gen f 3.0 n 100 swA.dat sine_gen f 11.0 n 100 swB.dat add swA.dat swB.dat composite.dat xgraph a pl composite.dat time.title & fft composite.dat composite.fft cmag composite.fft composite.spectrum xgraph composite.spectrum spectrum.title & ) Try: source script_convolve.com ( convolve sequenceA.dat sequenceB.dat sequenceC.dat xgraph sequenceC.dat ) Try: source script_image.com ( sine_gen n 100 f 2 realvec v.dat outpr v.dat v.dat m.dat mat2image m.dat m.ppm xv m.ppm ) Try: source script_color_image.com With this scheme, other formats could be defined, such as integer vectors, or higher dimensional matrices, but no such formats are presently used. Optional comment fields can be added by starting with "!". Everything after the "!" until end of line is considered a comment. Comment fields can also be added by using the Cstyle comment designators, "/*" and "*/". These may span multiple lines. See also:
(Questions, Comments, & Suggestions: xgraphadmin@xgraph.org)
