This library aims to be an almost exact clone of Pylab and to integrate the core parts of NumPy/SciPy/some of Matplotlib to provide a Matlab-like interface. The reason this library was developed to provide an easy translatation between complicated signal processing algorithms and mobile apps.

Since this library only aims to provide easy conversion and not easy developement, there are areas that are a bit of a pain. For example, you can’t assign x[0..<N] = 0; instead you have to use x[0..<N] = zeros(N) or think of clever hacks like x[0..<N] *= 0.

This library almost exactly tries to copy the NumPy syntax. While the mathematical functions do this, one notable exception is Python’s for i in arange(N). To get the same result in swix, use for i in arange(N).grid.

If in doubt or getting weird compiler errors, look at the corresponding NumPy docs (I tried to include links) or look at the section on Bugs you may find.


This page only includes functions. All constants are defined in numbers.


numbers_swix.binom(n, k) Calculate the binomial coeffecint or n choose k.
numbers_swix.close(x, y) See if two numbers are approximately equal.
numbers_swix.convience_elements() The built in numeric classes have convience elements.
numbers_swix.deg2rad(x) Convert from degrees to radians.
numbers_swix.factorial(n) Computes \(n \cdot (n-1) \ldots 2 \cdot 1 = n!\)
numbers_swix.isNumber(x) See if the input object is a number.
numbers_swix.operator_slash(lhs, rhs) Operator / converts integer divison to double division.
numbers_swix.rad2deg(x) Convert from radians to degrees.


io_swix.read_binary(x, filename)
param x:What to write to a file.
io_swix.read_csv(filename) Reads a CSV.
io_swix.write_binary(x, filename)
param x:The content to write to a file.
io_swix.write_csv(x, filename, header) Writes a CSV.



vector.initing.arange(max[, min, x]) Makes an array of integers.
vector.initing.array(numbers) Makes an array out of a list of numbers.
vector.initing.asarray(x) Convert the input to an vector.
vector.initing.copy(x) Copies the contents of an array.
vector.initing.linspace(min, max[, num]) Makes a series of values linearly interpolated between two poitns.
vector.initing.ones(N) Makes an array of ones.
vector.initing.ones_like(x) Makes an array like another array.
vector.initing.rand(N[, distro]) Makes an array of uniform random variables.
vector.initing.randn(N[, mean, sigma]) Makes an array of normally distributed random variables.
vector.initing.randperm(N) Shuffle an array of (typically) indices.
vector.initing.seed(N) Sets the seed for a psuedo-random number generation.
vector.initing.zeros(N) Makes an array of 0’s.
vector.initing.zeros_like(x) Makes an array like another array.


vector.helper_functions.argmax(x) The location of the maximum.
vector.helper_functions.argmin(x) The location of the minimum.
vector.helper_functions.argsort(x) Sort the array but using indices.
vector.helper_functions.argwhere(idx) Sees where a condition exists.
vector.helper_functions.clip(a, a_min, a_max) Only keep values between a_min and a_max; set the rest to 0.
vector.helper_functions.concat(x, y) Concatenates two arrays.
vector.helper_functions.count_nonzero(x) Counts the nonzero elements.
vector.helper_functions.cumprod(x) Find the cumulative product of every element in this array.
vector.helper_functions.delete(x, idx) Deletes elements.
vector.helper_functions.in1d(x, y) Sees if elements from the first array are in the second and returns the indices.
vector.helper_functions.intersection(x, y) Find elements that are both arrays.
vector.helper_functions.logical_and(x, y) Find the logical AND of x and y.
vector.helper_functions.logical_not(x) Find the logical NOT of x and y.
vector.helper_functions.logical_or(x, y) Find the logical OR of x and y.
vector.helper_functions.logical_xor(x, y) Find the logical XOR of x and y.
vector.helper_functions.norm(x[, ord]) Finds the norm of an array.
vector.helper_functions.println(x[, prefix, ...]) Prints an array.
vector.helper_functions.prod(x) Find the product of every element in this array.
vector.helper_functions.repeat(x, N[, axis]) Repeats an array.
vector.helper_functions.reverse(x) Reverses an array.
vector.helper_functions.shuffle(x) Randomly shuffle an array.
vector.helper_functions.sort(x) Sorts an array.
vector.helper_functions.union(x, y) Finds unique elements that are in either array.
vector.helper_functions.unique(x) Find the unique elements of an array.


vector.vector.copy() Copies the contents of an array.
vector.vector.indexing(idx) Grabs elements using an vector, Range<Int> or integers.
vector.vector.max() Finds the maximum value.
vector.vector.mean() Finds the average value.
vector.vector.min() Finds the minimum value.
vector.vector.reshape(shape) Reshapes the matrix to the specified size.
vector.vector.reverse() Reverses the array in place.
vector.vector.sort() Sorts the array in-place.


vector.complex_math.fft(x) Takes the discrete Fourier Transform.
vector.complex_math.fftconvolve(x, kernel) Convolve x with a kernel.
vector.complex_math.ifft(y_real, y_imag) Takes the inverse Foureir Transform.


vector.simple_math.abs(x) Finds the absolute value of an array.
vector.simple_math.apply_function(function, x) Apply a function to every element of an array.
vector.simple_math.ceil(x) Ceil’s each element.
vector.simple_math.cos(x) Finds the cos of an array.
vector.simple_math.cumsum(x) Finds the cumulative sum of an array.
vector.simple_math.exp(x) Finds the exponent of each element; mathematically it finds
vector.simple_math.exp2(x) Finds \(2^x\) for some array x.
vector.simple_math.expm1(x) Estimate \(\exp(x)-1\).
vector.simple_math.floor(x) Floors each element.
vector.simple_math.log(x) Finds the log base e of an array.
vector.simple_math.log10(x) Finds the log base 10 of an array.
vector.simple_math.log2(x) Finds the log base 2 of an array.
vector.simple_math.max(x[, y]) Finds the maximum element.
vector.simple_math.mean(x) Finds the mean of an array.
vector.simple_math.min(x[, y]) Finds the maximum element.
vector.simple_math.pow(x, power) The power of a {Double, vector} to {Double, vector}
vector.simple_math.remainer(x1, x2) Finds the element wise remainder after dividing the two arrays.
vector.simple_math.round(x[, decimals]) Rounds each element.
vector.simple_math.sign(x) Finds the sign an array.
vector.simple_math.sin(x) Finds the sin of an array.
vector.simple_math.sqrt(x) Takes the sqrt of each element.
vector.simple_math.std(x) Finds the standard deviation of an array.
vector.simple_math.sum(x) Finds the sum of an array.
vector.simple_math.tan(x) Finds the tan of an array.
vector.simple_math.variance(x) Finds the variance of an array.


vector.operators.assignment_operator(lhs, rhs) Assign select values of an array to a value.
vector.operators.elementwise_operators(lhs, rhs) Element-wise operators.
vector.operators.equality(lhs, rhs) Seeing if two arrays are about equal.
vector.operators.logical_operators(lhs, rhs) Logical operators.
vector.operators.pow(lhs, rhs) The power operator.



matrix.initing.array(matlab_like_string) An array from a matlab like string.
matrix.initing.eye(N) Makes the identity matrix.
matrix.initing.meshgrid(x, y) Makes a mesh out of two vectors.
matrix.initing.ones(shape) Makes a matrix full of ones.
param x:
param x:
matrix.initing.reshape(x, shape) Reshapes to the specified size.
matrix.initing.zeros(shape) Makes a matrix full of zeros.
matrix.initing.zeros_like(x) A matrix like the other matrix.


matrix.helper_functions.argwhere(idx) Sees where a condition applies.
matrix.helper_functions.det(x) Estimate the determinant of a matrix.
matrix.helper_functions.diag(x) Make an array with the specified diagonal.
matrix.helper_functions.fliplr(x) Flips each row.
matrix.helper_functions.flipud(x) Flips each column.
matrix.helper_functions.kron(a, b) Find the Kronecker product between two matrices.
matrix.helper_functions.norm(x[, ord]) Find the Matrix norm of a matrix.
matrix.helper_functions.ones_like(x) Makes an matrix like another matrix.
matrix.helper_functions.println(x[, prefix, ...]) Prints the matrix.
matrix.helper_functions.rot90(x[, k]) Rotate the given matrix 90 degrees counter-clockwise.
matrix.helper_functions.transpose(x) Finds the transpose.


matrix.matrix.copy() Copies the matrix.
matrix.matrix.dot(x) Matrix multiplication with another matrix.
matrix.matrix.index(one, two) Indexes with two numbers; range<int>, vector or int.
matrix.matrix.index_diag(string) Gets or sets the diagonal.
matrix.matrix.index_flat(idx) Indexes in the row-major flat array.
matrix.matrix.tril(x) Return the indices to the lower part of the array.
matrix.matrix.triu(x) Return the indices to the upper part of the array.


matrix.complex_math.dot(A, x) Matrix multiplication between two matrices.
matrix.complex_math.eig(x) Find the eigenvaleus of a matrix.
matrix.complex_math.inv(x) Find the inverse of a matrix.
matrix.complex_math.pinv(x) Finds the Moore-Penrose pseudoinverse.
matrix.complex_math.rank(x) Compute the matrix rank of a matrix.
matrix.complex_math.solve(A, b) Solve a system of linear equations.
matrix.complex_math.svd(x[, compute_uv]) Compute the singular value decomposition.


matrix.images.RGBAToUIImage(r, g, b, a) Convert the RGBA color planes into a UIImage
matrix.images.UIImageToRGBAImage(image) Convert an RGBA UIImage into 4 different arrays corresponding to the RGBA color planes.
matrix.images.imshow(x) Shows a matrix using Python.
matrix.images.resizeImage(image, shape) Resize an image to the given shape.
matrix.images.rgb2hsv(r, g, b) Converts RGB values to HSV values.
matrix.images.rgb2hsv_vplane(r, g, b) Converts a set of RGB color values to the HSV v plane only.
matrix.images.savefig(x, filename[, save, show]) Saves a figure using Python.


param x:
param x:
param x:
param x:
param x:
matrix.simple_math.mean(x[, axis])
param x:
matrix.simple_math.pow(x, power)
param x:
matrix.simple_math.prod(x[, axis]) Find the product of each row/column of a matrix.
param x:
param x:
param x:
param x:
matrix.simple_math.sum(x[, axis]) Perform the sum over a given axis.
param x:


matrix.operators.assignment_operator(lhs, rhs) Assign select values of a matrix to a constant value.
matrix.operators.element_operators(lhs, rhs) Element wise artithmetic operators.
matrix.operators.equality(x, y) Sees if two matrices are approximately equal.
matrix.operators.solve(A, b) Solves a system of eqautions similar to Matlab’s backslash.

machine learning


param responses:
 The response to some unknown variable.
machine_learning.SVM.setParams(svm_type, kernel)
param svm_type:Assumed to be either C_SVC, ONE_CLASS, NU_SVC or NU_SVR
machine_learning.SVM.train(responses, targets)
param resonses:The matrix of responses to some (known!) variable.


machine_learning.kNN.predict(x, k)
param x:The reponse you want to train for.
machine_learning.kNN.train(responses, targets)
param responses:
 The responses.


param x:The vector you want to take the address of.