Compatibility with Matlab Functions

Black-box operators are powerful enough to act as a matrix with a number of standard Matlab functions. Some of this functionality is native to the operators, some have been implemented as adapters, and others work without any particular attention.

This page contains a list of functions that works in a way that is similar to standard Matlab functions. These functions are not included in the normal function list, since their syntax is given by Matlab conventions.

There are a few quirks, however, that one should be aware of. These are explained below. The main place where one needs to be careful is the matrix multiplication, which may be ambigous in certain cases.

Contents

   Operators Support for syntactic elements
Basic Information Information about an operator
Operations Black-box replacements for Matlab operations
Analysis Supported function in matrix analysis
Iterative Algorithms Support for iterative algorithms shipped with Matlab
Miscellaneous Other functions

Special considerations

Equation Solving Caveats with equation solving
Unsupported Operations Functions that are unsupported or behave unexpectedly

Notation

Sometimes it is easiest to illustrate a syntax by example. We use A and B represent matrices or black-box operators, c represent a scalar, and str is a string.

Operators

Many of the normal operators works with the regular Matlab syntax. This accounts for the fact that a black-box operator can be used as a matrix in many situations. It also makes black-boxes pleasant to work with.

Transposition
Complex conjugate transpose
Plus
, Minus
Unary plus
Unary minus
Horizontal concatenation
Vertical concatenation
Division by a scalar (see also equation solving)

Matrix multiplication

BBTools supports matrix multiplication via the normal syntax and . However, to maximize compatibility there are special rules which applies to this product:

The convention allows a black-box operator to replace a Matlab matrix in many circumstances. If A is a black-box operator and x is a normal matrix, then y=A*x evaluates the matrix-vector product, while bb=A*blackbox(x) creates a black-box operator.

If you need to create a black-box, please use bbprod which always returns a black-box operator.

Basic Information

Functions that works as in the normal way includes:

Size of a black-box operator
true for a real operator, false if it is complex

true if A is the class specified in str

Note: isa have been extended for black-box operators.

The following functions also works as expected, although the output differ from the normal because a black-box differs from a Matlab matrix:

Display evaluation tree, without printing the name
As disp, except the name is printed

Operations

These functions creates a black-box operator equivalent to the operation normally performed by Matlab. They generally work as expected, except the result is a black-box.

All operations in BBTools support complex operators.

Kronecker tensor product
Replicate and tile an array

Operations on complex operators.

Complex conjugate
Complex real part
Complex imaginary part

Note: kron and repmat have counterparts in BBTools (bbkron and bbrepmat) that always produce a black-box operator, even if the input are Matlab matrices.

Caveat: real and imag evaluate two products with the operator when it evaluates a product (unless they get a real operator as input). This could potentially lead to an exponential explosion in the evaluation time, if they are nested.

Analysis

These functions generally work as expected. However, they are implemented using iterative methods, which may sometimes give a slighly different behavior.

Norm of an operator (warning except for 2-norms)
Less accurate, but slighly faster, way to compute the 2-norm
Estimate the 1-norm of an operator

Note: BBTools includes bbnormest, which should be used instead of normest everywhere. It supports both 1-, 2-, and -norms, usually with much better accuracy for substantially less work than normest.

Except for the 2-norm, norm reverts to bbnormest with a warning. This is intended to prevent putting too much trust into an estimate.

Limitation: Currently, BBTools does not include functions to estimate the Frobenius norm of an operator.

Iterative Algorithms

Some care have been taken to allow the iterative routines shipped with Matlab, to work with black-box operators. Matlab usually assumes that these functions are intended for sparse matrices, but they work for black-box operators as well.

Find a few eigenvalues and eigenvectors
Find a few singular values and vectors
Iterative solver (Conjugate Gradients on the Normal Equations)
Iterative solver (BiConjugate Gradients)
Iterative solver (BiConjugate Gradients Stabilized)
Iterative solver (Conjugate Gradients Squared)
Iterative solver (Generalized Minimum Residual)
Iterative solver (Minimum Residual)
Iterative solver (Preconditioned Conjugate Gradients)
Iterative solver (Quasi-Minimal Residual)
Iterative solver (Symmetric LQ)

Caveat: In certain modes of operation, eigs and svds expects that the operator can be inverted. This is not supported by BBTools.

Miscellaneous

This is a catch-all for everything that does not fit comfortably anywhere else. The following functions works as expected.

Sum of elements
Average or mean value

Equation Solving

The normal Matlab-syntax for solving a linear system is or . For large-scale problems it is usually necessary to use an iterative routine, e.g. bbsolve, possibly using a preconditioner to get convergence.

Unfortunately, there is not a single, unattended algorithm that always attains this goal. Among other things, BBTools was written to make it easier to reasearch this kind of algorithms for realistic and relevant large-scale problems.

For this reason BBTools does not support the shorthand notation used by Matlab. Instead, please call either bbsolve or an iterative algorithms shipped with Matlab.

Unsupported Operations

Basically, nothing is supported unless explicitly stated otherwise. However, there are a few corner cases it is wise to be aware of.

Some common operations goes against the spirit of BBTools. is not supported directly. Instead you should create an operator via bbindex which performs a similar operation.

Not all functions can be supported from matrix-vector products alone. The following operations will most likely never be supported by BBTools.

Hadamard product, direct product, or array multiply
Array power
Absolute value

Functions with unexpected behaviour

The following functions are not implemented, and works unexpectedly. They consider a black-box as an array of objects, rather than addressing the black-box they get as input. It is being considered whether it would be appropriate to change this behaviour.

Length of the array of black-boxes
true for an empty black-box array