CodePlexProject Hosting for Open Source Software

au_ad_bundle_fun.m

AU_AD_BUNDLE_FUN Objective function for bundle

params = [r1 r2 r3 -- Rodrigues rotation (axis * angle)

t1 t2 t3 -- translation

f u0 v0 -- calibration

k1 k2 -- radial

X1 X2 X3 X4 -- 3D point]

out = [projected_x, projected_y]

C = R * pi(X) + T

c = pi(C)

d = radial(c, [k1 k2]);

out = f * d + [u0 v0];

au_assert.m

AU_ASSERT Assert all(EXPR), print expr if not

au_assert('det(M) > 0');

au_assert_equal.m

AU_ASSERT_EQUAL Assert all(EXPR1 == EXPR2), print expr if not

au_assert_equal('det(M)','0'[,TOLERANCE][,VERBOSE]);

TOLERANCE < 0 means relative tolerance of

abs(TOLERANCE) * max(abs(EXPR1) + abs(EXPR2))

NaNs are assumed unequal, as it's consistent with isequal,

and it's often useful to be told there are nans...

au_autodiff_generate.m

AU_AUTODIFF_GENERATE Generate code for function and derivatives

To generate C code for a function and its jacobian, use

STR = AU_AUTODIFF_GENERATE(FUNCTION_HANDLE, EXAMPLE_ARG, EXAMPLE_DATA)

or

AU_AUTODIFF_GENERATE(FUNCTION_HANDLE, EXAMPLE_ARG, EXAMPLE_DATA, FILE)

The first form returns the core code in a string, the second wraps

it in a MEX wrapper, and stores it in file FILE.

The EXAMPLE_ARG and EXAMPLE_DATA are used to determine the size, and

to perform finite-difference checks just in case...

FUNCTION_HANDLE must take a column vector and return a column vector.

It can also take an optional argument DATA.

au_ccode.m

AU_CCODE Generate optimized C code from symbolic expression.

AU_CCODE(SYMEXPR) returns a string

AU_CCODE(SYMEXPR, FILENAME) writes to FILENAME

AU_CCODE(SYMEXPR, FILENAME, 0) turns off CSE

EXAMPLE:

syms x y real

au_ccode(x^3 + x^2*y)

au_ccode(simplify(x^3 + x^2*y))

au_check_derivatives.m

AU_CHECK_DERIVATIVES Finite-difference derivative check

emax = au_check_derivatives(f,x,J, opts)

With opts an au_opts structure defaulting to

delta = 1e-4 -- Added to each element of x

tol = 1e-7 -- Want derivatives accurate to this tolerance

timeout = inf -- Spend at most "timeout" seconds checking

verbose = 1 -- Be verbose

PatternOnly = 0 -- Used for checking JacobPattern

au_coeff.m

AU_COEFF Extract polynomial coefficients from symbolic expr

coeffs = au_COEFF(a + b*x + c*x^6, x)

au_cross_matrix.m

AU_CROSS_MATRIX Cross-product matrix of a vector

M = AU_CROSS_MATRIX(W) Creates the matrix

[ 0 -w3 w2 ]

[ w3 0 -w1 ]

[-w2 w1 0 ]

au_deep_print.m

AU_DEEP_PRINT Hierarchical print of object.

au_deep_unvectorize.m

AU_DEEP_UNVECTORIZE Unflatten arbitrary structure/cell from a linear vector x.

x = au_deep_vectorize(obj)

obj1 = au_deep_unvectorize(obj, x) % use obj as a template

au_assert_equal obj obj1

au_deep_vectorize.m

AU_DEEP_VECTORIZE Flatten arbitrary structure/cell a linear vector x.

x = au_deep_vectorize(obj)

obj1 = au_deep_unvectorize(obj, x) % use obj as a template

au_assert_equal obj obj1

au_fscan_regexp.m

AU_FSCAN_REGEXP File scan line by line splitting on regexp

out = au_fscan_regexp(fid, delim_re)

Return cell array of cell arrays of strings

au_levmarq.m

AU_LEVMARQ Home-grown LM with line search

[x, J, log] = au_levmarq(x, f, opts)

x: Initial estimate

func: Function to be called.

opts: Algorithm options (see below)

For some problems, matlab's lsqnonlin will be better than

this, but this is useful as a "bare bones" implementation

that you can modify.

OPTIONS:

To get a default options structure, use

OPTS = AU_LEVMARQ('OPTS');

EDIT AU_LEVMARQ % to see options descriptions

LOG:

Optional third argument LOG has rows

[lambda, function_value, linmin_t, funevals]

au_logsumexp.m

AU_LOGSUMEXP Compute log(sum(exp(M))) stably

au_logsumexp(M) = log(sum(exp(M)))

but avoids under/overflow.

[L, Jacobian] = au_logsumexp(M) returns the Jacobian

Notice that although sum operates along columns,

L is returned as a column vector so that the Jacobian

makes sense.

au_map.m

AU_MAP Map function over container.

Combines behaviours of cellfun, arrayfun, with more

automatic inference of output type.

Examples:

au_map(@num2str, rand(3,3)) % produces cell array of strings

au_map(@exp, rand(3,3)) % produces numeric array

au_map(@max, rand(3,3), rand(3,3)) % map binary function

au_mat2str.m

AU_MAT2STR Convert matrix to printable string

S = au_MAT2STR(M, DIGITS, MAX_ELEMENTS)

au_mfilename.m

AU_MFILENAME Return filename of caller, or "[base workspace]"

OFFSET = -1 is caller's caller...

au_opts.m

AU_OPTS Easy option parsing

opts = AU_OPTS('FlagA=0', 'FlagB=3;Algo=foo', varargin{:})

is all you need to remember. The defaults are listed first,

the varargs override them if necessary. An existing opts

struct can be one of the args, and its fields are also added

with overwrite.

Any value beginning with a digit (or 'inf') is passed to str2double,

any other is left as a string.

To add more complex datatypes, use a struct.

au_prmat.m

AU_PRMAT Compact print of matrices.

PR(A,B,C,...);

Displays matrices in a compact 7-chars-per-column

format. The format uses 'm' notation to save a char

for small numbers, so that -2.345e-12 gets more sigfigs:

|-2.3e-12 -- won't fit (8 chars)

| -2e-12| -- doesn't use all 7 chars

|-23e-13| -- 7 chars, extra sigfig

|-234m14| -- 7 chars, 2 extra sigfigs

Even in 5 chars, get extra sigfigs

| -23m7| -- 4 chars

Exact zeros are marked with 'o'

Printing concats horizontally (it's easy

to concat vertically just by repeat calling)

au_ransac.m

AU_RANSAC Ransac loop

OPTS = au_RANSAC('opts', NDATA, NSAMPLES);

au_RANSAC(OPTS)

OPTS.NDATA

Number of points

OPTS.NSAMPLES

Number of points to pass to the fit function

OPTS.MAXITERS

Max #iterations

OPTS.THRESHOLD

Outlier threshold - needed for convergence

computation. Defaults to >= 1 so that top-hat

error functions mark outliers.

OPTS.FIT(INDICES)

A function handle which returns a vector of

parameters given a minimal set of indices

OPTS.COMPUTE_RESIDUALS

A function handle which returns a vector of

parameters given a minimal set of indices

OPTS.OUTPUT

au_ransac_demo.m

AU_RANSAC_DEMO Example of use of au_ransac

au_reduce.m

AU_REDUCE Apply binary function to container elements, left-associative

au_rodrigues.m

AU_RODRIGUES Convert axis/angle representation to rotation

R = AU_RODRIGUES(AXIS*ANGLE)

R = AU_RODRIGUES(AXIS, ANGLE)

This is deigned to be fast primarily if used with au_autodiff

au_root_dir.m

AU_ROOT_DIR Return path to root of awful/matlab

au_rosenbrock.m

AU_ROSENBROCK Rosenbrock

au_run_tests.m

AU_RUN_TESTS Run all tests in the library

au_sparse.m

AU_SPARSE Create sparse matrices with low time/space overhead.

This takes the same arguments as sparse(), but insists

that the indices are in the correct order for Matlab's

internal format (compressed sparse column), see

http://www.mathworks.co.uk/help/matlab/math/accessing-sparse-matrices.html

That means that in the call

au_sparse(i,j,v)

we require

1. The columns j should be monotonic, i.e. all(diff(j)>= 0)

2. The rows i should be monotonic within columns, i.e:

all(diff(i(j==k))>0) forall k=1:max(j)

au_sprand.m

AU_SPRAND Like sprand, but faster.

Type HELP SPRAND for more info

au_strip_path.m

AU_STRIP_PATH Remove directories matching REGEXP from PATH

new_path = au_strip_path(path, RE)

Assumes PATH is a semicolon-separated string

au_system.m

AU_SYSTEM Issue system command with matlab-separated arguments

The matlab system command requires you to generate a command

string rather than passing separate arguments

For example,

system('dir', '/w', '*.m') fails oddly

au_system('dir', '/w', '*.m') -> !dir /w "*.m"

Specifically, it encases arguments in double quotes

if they contain spaces or special characters, and

generates a string that is passed to the OS command.

au_test_assert.m

AU_TEST_EQUAL Test EXPR1 == true, print result

We call with strings rather than values to give much better

error messages. The strings are evaluated in the caller's

context, so should behave sensibly.

au_test_equal.m

AU_TEST_EQUAL Test all(EXPR1 == EXPR2), print result

au_test_equal det(M) 0 1e-7

au_test_equal('det(M)','0',1e-7);

au_test_equal 16+1 17

We call with strings rather than values to give much better

error messages. The strings are evaluated in the caller's

context, so should behave sensibly.

au_test_regexp.m

AU_TEST_REGEXP Test that string matches regex

au_test_regexp(sprintf('%.3f', 4), '\d+\.\d')

au_test_should_fail.m

AU_TEST_SHOULD_FAIL Test that EXPR throws an error

au_whist.m

AU_WHIST Weighted histogram</body></html>

H = AU_WHIST(I, WEIGHTS, IMAX);

is the same as H = full(sparse(1, I, WEIGHTS, 1, IMAX));

but much faster.

Last edited Aug 4, 2014 at 10:40 PM by awfidius, version 13