Version 2.0 alpha
Description
The focus of this library is on the data structures and algorithms used within the fields of bioinformatics and molecular modelling. The approach used closely follows that of the Standard Template Library (STL) which is part of ISO/ANSI standard C++. This library uses templates to implement generic programming. Templates allow the development of efficient generic programming modules using compile-time mechanisms. Although the BTL has been designed with biomolecular applications in mind it contains classes of more general utility. For instance, the Matrix class could be used for matrix algebra in many contexts. There are many freely available matrix classes that pre-date the one we have written but non are well suited to our needs. Most provide many functions that unlikely to be used by bioinformatics and molecular modelling applications. We aim to provide an extremely simple matrix class to be used by people who may not have a particularly strong mathematical background.
Floating Point Precision
The floating point precision of the library as a whole is defined as the user defined type BTL_REAL. A typedef statement in the BTL.h. e.g.
typedef double BTL_REAL;
To change the precision used simply alter this statement and recompile the library. Of course not all floating point variables in the library are of type BTL_REAL, some, for instance, are fixed at type double to avoid large round off errors. In spite of this, setting BTL_REAL to be of type float may well result significant round off problems in certain calculations such as those used by the Matrix::Eigens() method.
Debugging Version of Library
If the DEBUG_VERSION symbol is defined then the library will carry out extra error checking such as some array bounds checking. This checking will obviously make the library more robust but will also increase excecution times. Simply comment the define statement in the BTL.h file out if the extra checking is not required.
BTL_Vector
his class represents a mathematical vector of any
dimension.
V = xi + yj + zk + ...
However, its primary use will probably in representing the position of atoms in three dimensions. The default contructor contructs a 3D BTL_Vector.
There are several types associated with this class:
value_type
: same as the type BTL_REAL which is defined in
BTL.h
iterator
: this is a STL type iterator. It can be used to
sequentailly access the elements of the BTL_Vector e.g.
const_iterator
BTL_Vector v1;
...
for (BTL_Vector::iterator i = v1.begin(); i != v1.end(); i++)
cout << *i;
: used to access const BTL_Vector.
size_type
: this is an unsigned integer type that represents
the size of any BTL_Vector object.
Authors: W.R.Pitt, D.S.Moss
Files: Vector.h,
Vector.cpp
Friends: Friend equivalents to some functions are available and are
documented with these functions. Also available is: friend
ostream& operator<<(ostream &os, const BTL_Vector &m);
Dependencies: BTL_NumericLimits
BTL_NumericUtilities
Operations
BTL_Matrix
This class represents a mathematical Matrix of any dimension. Matrices
where one of the two dimensions is unity are more efficiently modelled
using the BTL_Vector class.
There are two types associated with this class:
value_type
: this type is the same as the
BTL_Vector::value_type and defines the type of the elements of the Matrix.
size_type
: this type is the same as the BTL_Vector::size_type and
defines the type of the Matrix indexes. It should always be an unsigned
integer type.
Authors: D.S.Moss, W.R.Pitt, I.Tickle.
Files: Matrix.h,
Matrix.cpp
Friends: Friend equivalents to some functions are available and are
documented with these functions. Also available is: friend
ostream& operator<<(ostream &os, const BTL_Matrix &m);
Dependencies: BTL_Vector,
BTL_NumericLimits,
BTL_NumericUtilities
Operations
A = U * diag(L) * V.transpose() where A is this
Matrix.
On completion, this matrix is overwritten with matrix U,
the diagonal of matrix diag(L) is written over the input
BTL_Vector L and Matrix V replaces the input Matrix.
BTL_CholeskyInverse
Inverts a symmetric positive definite matrix. Employs Cholesky
decomposition in step (1). (1)M=LL(tr) (2)compute L(-1)
(3)M(-1)=L(-1)(tr)L(-1)
Input should be a symmetric positive definite matrix. Only the lower
triangular matrix containing the lower triangle of M and overwritten with
L then with L(-1) and finally with the lower triangle of M(-1)
Authors: D.S.Moss, W.R.Pitt
Files: CholeskyInverse.h
Dependencies: BTL_NumericLimits
Prerequisites: The matrix class used as the template parameter must
contain the following features:
1. value_type - the type of elements in a matrix
2. size_type - the subscript type
3. size_type num_rows(); - function to return the number of rows
4. size_type num_cols(); - function to return the number of columns
5. value_type operator()(size_type,size_type); - return individual elements of the matrix by the index of the row then the column. Indices should start at 1.
Operations
BTL_FFT
This routine may be used to carry out a One-dimensional, Two-dimensional,
or Three-dimensional Fast Fourier Transform. The basic algorithm has been
adapted from freely-distributed code issued by the HP Reference Library
It is based on the Cooley-Tukey algorihm (decimation in time), and
it caters for sizes of the input array which are not a power of two.
The input parameters are;
First Input Parameter: A one, two or three-dimensional object, from the Fastft class. Second Input Parameter: A boolean variable. When set to 'true', this gives the 'forward' transform.
Note: in the comments following, the term 'array' is used to refer to the object created using the Fastft class.
Operation: The routine carries out the standard Fast Fourier Transform. It checks to see if the size of the array is divisible by any of the first 12 primes. If it is it continues using the usual algorithm. It copies z1 to z2 as it proceeds, and the next time around uses z2 as the input array. Each iteration the variable 'arg' is set to 1, and 'omega' is set to the appropriate value. Arg is then multiplied by omega to give the relevant roots of unity. (For example, if n=8, in the first iteration -1 and 1 is used, then -i, 1, i, and -1, then in the last iteration the 8 '8th roots' are used). The routine should still work if the array size contains a factor which is not one of the first 12 primes. However it may be preferable to increase the number of primes in this case (in the 'prime' array), or alternatively pad the array with extra data points to ensure it is divisible by one of the 12 primes, or preferably a power of a prime.
Warnings: 1. This routine does divide by n when doing the 'forward' transform. This is useful if the routine is used to transform forward and then back again. Most routines seem to leave this 'division by n' to the calling routine, however it is more sensible to let the calling routine 'multiply by n' if there is ever a need to do so. (E.g. (1, 0, 0, 0) will 'forward' transform to (.25, .25, .25, .25), and will then transform back to (1, 0, 0, 0).)
2. The calculation will leave small 'epsilon' values in the array where the value is calculated as zero. The calling routine should take whatever action is required.
Acknowledgements: This routine was originally adapted from code which
has been circulated freely from the standard Hewlett-Packard Reference
Library. It is essentially the same routine with the addition of the
'esign' variable, which allows 'reverse' transforms as well as
'forward' transforms; and with 'division by n' during the forward transform.
The HP code was initially transcribed from Fortran as presented in
'FFT as Nested Multiplication, with a Twist' by Carl de Boor in
SIAM Sci. Stat. Comput., Vol 1 No 1, March 1980.
Authors: B.Sweeney, W.R.Pitt
Files: FFT.h
Dependencies: none
Operations
BTL_Vertex
This class encapsulates a graph vertex and is designed for use with the
BTL_Graph class. Each vertex contains a reference to a data object and
pointers to other vertices. It is a template class the single template
parameter is a type of dereferencer.
Authors: W.R.Pitt
Files: Graph.h
Dependencies: BTL_II, and
BTL_IteratorDerefencer, or
BTL_InDencer
Generalizations
Specializations
Operations
BTL_Graph
Graph container with any type of data at vertices of the graph and no data
associated with edges. The default behaviour is have undirected edges.
This can be changed to directed if specified in the constructor. No
self links (edges from one vertex to itself) are allowed.
Authors: W.R.Pitt
Files: Graph.h
Friends: operator<<
Dependencies: BTL_VertexBase and its subclasses.
Specializations
Operations
BTL_VertexWithEdges
This class represents an vertex that has links to edge
objects. It is to be used in combination with class BTL_GraphWithEdges.
Authors: W.R.Pitt
Files: GraphWithEdges.h
Friends: friend class BTL_GraphWithEdges<T1,T2>>;
friend ostream& operator<<(ostream &os,
const BTL_VertexWithEdges &m);
Dependencies: None, except by inheritance.
Generalizations
Operations
BTL_Edge
This class represents an edge of a graph. It is to be used
in combination with class BTL_GraphWithEdges.
Authors: W.R.Pitt
Files: GraphWithEdges.h
Friends: friend class BTL_GraphWithEdges<T1,T2>>;
friend ostream& operator<<(ostream &os,
const BTL_Edge &m);
Dependencies: BTL_VertexWithEdges
Generalizations
Operations
BTL_GraphWithEdges
Graph container with any type of data at the vertices of the graph and any
type of data at the edges. The default behaviour is have undirected
edges. This can be changed to directed if specified in the
constructor. No self links (edges from one vertex to itself) are allowed.
Authors: W.R.Pitt
Files: GraphWithEdges.h
Friends: friend ostream&
operator<<<(ostream &os, const BTL_GraphWithEdges &m);
Dependencies: BTL_Vertex,
BTL_II
Generalizations
Specializations
Operations
BTL_DFSIterator
This is a an iterator for iterating over a connected sub-graph in depth
first order. It is designed to work with the BTL_Graph and
BTL_GraphWithEdges but takes that type of graph as its template parameter
and could be used on any graph and vertex type if they have a given set of
functions.
Authors: W.R.Pitt
Files: DFSIterator.h
Dependencies: None
Operations
BTL_ConstDFSIterator
The const version of the BTL_DFSIterator.
Authors: W.R.Pitt
Files: DFSIterator.h
Dependencies: None
Operations
BTL_LeastSquaresFit
This class contains methods for calculating the applying
the least squares fit of one set of x,y,z coordinates onto another. The
method used is that of Simon K. Kearsley (Acta Cryst.'89, A45, 208-10).
Usage: All members in this class are static and therefore an object
need not be create before the members can be used. The methods in this
class are generic algorithms and can be used with a wide range of
container types. This flexibility is achieved through the use of
iterators. Any container used must have an appropriate iterator type
that can be used to traverse through its elements. Most methods require
two iterators per container, marking the first and last element to be
processed. This style of function is designed to be the same as used in
the Standard Template Library.
e.g.
typedef vector::iterator iterator;
// Construct two empty vectors
vector v1,v2;
// Put some coordinates into these vector
....
// Do least squares fit on these coodinates
BTL_REAL rmsd =
Fitter::Fit(v1.begin(),v1.end(),v2.begin(),v2.end());
// Set up aliases of the type to be used
typedef vector::const_iterator const_iterator;
typedef LeastSquaresFit<iterator,const_iterator> Fitter;
Files: LeastSquaresFit.h
Dependencies: BTL_Matrix,
BTL_NumericLimits
Authors: W.R.Pitt, D.S.Moss
Operations
BTL_PDBSort
This class defines a functor or function object which can be used by
a generic sort routine to sort atoms into the order used in
Brookhaven pdb format files. Order is defined by strings, 2 or 3
characters long.
Authors: W.R.Pitt
Files: PDBSort.h,
PDBSort.cpp
Dependencies: none
Operations
BTL_AminoAcidProperty
This class defines a function object that will, given an
amino acid single letter code with return a property value for that residue
type.
Authors: W.R.Pitt
Files: AminoAcidProperty.h,
AminoAcidProperty.cpp
Dependencies: none
Operations
BTL_NumericLimits
This is a template class that can be used to return
standard floating point constants. N.B. This file will become obsolete when
the standard C++ file climits becomes more widely available. It contains a
numeric_limits class which will replace BTL_NumericLimits defined below.
Usage: e.g. const float EPSILON = BTL_NumericLimits<float>::epsilon();
Restrictions: This template class only works for float, double, and long
double types.
Authors: W.R.Pitt
Files: NumericLimits.h
Friends: None
Dependencies: None
Operations
BTL_NumericUtilities
This template class contains members which preform certain
numerical functions. The design of this class is not object-oriented and
the member functions could easily be provided as stand alone functions. The
reasons for containing the functions within a class is to put them into a
namespace and to make documentation easier. Standand C++ namespaces are
not still not implemented in many C++ compilers but otherwise this method
may well be better than putting the functions into a class. Most C++ design
and automatic documentation tools do not deal with non-class parts of a
library. We use Together/C++ for our documentation and this tool only
produces documentation for classes and class members.
Usage: e.g. unsigned int error =
BTL_NumericUtilities<float>::AreNotEqual(a,b);
Restrictions: This template class only works for float, double, and long
double types.
Authors: W.R.Pitt
Files: NumericUtilities.h
Friends: None
Dependencies: BTL_NumericLimits
Operations
N.B. The result can be out by 1 due to rounding errors in the
calculation which can occur for example when a float is converted to
a double. However, the result will never be greater than the
precision given in the constants mentioned above.
BTL_XYZProcessor
This is simple class for reading xyz format files.
It is really only included in the library so that real data can be used
in the test programs.
Friends: an output operator
Authors: W.R.Pitt
Files: XYZProcessor.h
Dependencies: None
Operations
Operations
Operations
A = U * diag(L) * V.transpose() where A is this
Matrix.
On completion, this matrix is overwritten with matrix U,
the diagonal of matrix diag(L) is written over the input
BTL_Vector L and Matrix V replaces the input Matrix.
N.B. The result can be out by 1 due to rounding errors in the
calculation which can occur for example when a float is converted to
a double. However, the result will never be greater than the
precision given in the constants mentioned above.
This page was created automatically using Together/C++ Information Export in
conjunction with the Borland C++ development suite.
BTL_PIRProcessor
This class is a simple PIR sequence file processor. It is
not complete and is only included for use by the demo programs that come
with this library. It can parse a PIR format containing any number
of sequences and provide the data as a vector
Authors: W.R.Pitt
Files: PIRProcessor.h,
PIRProcessor.cpp
Dependencies: none
BTL_PPMProcessor
This class is a simple ascii PPM image file processor. It
is not complete and is only included for use by the demo programs that come
with this library.
Authors: W.R.Pitt
Friends: ostream operator
Files: PPMProcessor.h,
PPMProcessor.cpp
Dependencies: none
BTL_Vector
BTL_Vector()
Constructs a 3D vector
and initialised each value to 0.0.
BTL_Vector(value_type p, value_type q, value_type r)
Constructs a 3D vector with initialization
and initialises the values with the numbers given.
BTL_Vector(size_type n)
Constructor for an n dimensional vector.
All n values initiated to 0.0.
BTL_Vector(size_type n, value_type v)
Constructor for an n dimensional vector.
All n values initiated to a value v.
BTL_Vector(const value_type* const array, const size_type& p);
Construct from a two dimensional array
of BTL_REALs ( given value_type* )
BTL_Vector(const BTL_Vector &v) : vec(v.vec)
Copy constructor.
~BTL_Vector()
Destructor.
iterator begin()
Returns iterator that can be used to
begin traversing through all elements of the BTL_Vector.
(There is also a const version of this function.)
iterator end()
Returns an iterator can be used in
comparison for ending traversal through the BTL_Vector.
(There is also a const version of this function.)
value_type& operator[](const size_type& i);
Returns the element, i positions
from the beginning of the BTL_Vector, in constant time.
(i >= 0). (There is also a const version of this
function.)
value_type operator[](const size_type& i) const;
size_type size() const
Returns the number of elements in the
BTL_Vector.
size_type dim() const
This function is added to give
compatibility with TNT.
value_type& operator()(const size_type& i);
Returns the i-th element in the BTL_Vector
(i >= 1). (There is a const version of this function as well).
value_type operator()(const size_type& i) const
bool operator==(const BTL_Vector& v) const;
Vector equality.
value_type MaxDifference(const BTL_Vector& v) const;
Returns the largest difference between
equivalent elements in this and BTL_Vector v.
BTL_Vector& operator=(const BTL_Vector &v)
Vector assignment.
BTL_Vector operator+(const BTL_Vector &v) const;
Vector addition.
BTL_Vector operator-(const BTL_Vector &v) const;
Vector subtraction.
BTL_Vector operator-() const;
Vector negation (unary minus operator).
BTL_Vector& operator+=(const BTL_Vector &v);
Vector increment.
BTL_Vector& operator-=(const BTL_Vector &v);
Vector decrement.
BTL_Vector operator+(const value_type &s) const;
Add a scalar to each element in
the BTL_Vector.
BTL_Vector operator-(const value_type &s) const;
Subtract a scalar from each element in
the BTL_Vector.
BTL_Vector& operator+=(const value_type &s);
Add a scalar to each element in
the BTL_Vector.
BTL_Vector& operator-=(const value_type &s);
Subtract a scalar from each element in
the BTL_Vector.
value_type operator*(const BTL_Vector &v) const;
Vector scalar/dot product.
BTL_Vector operator%(const BTL_Vector &v) const;
Vector cross product.
BTL_Vector operator*(const value_type& y) const;
Vector multiplication by a scalar.
BTL_Vector& operator*=(const value_type& y);
Vector multiplication by a scalar and
assignment.
BTL_Vector operator/(const value_type& y) const;
Vector division by a scalar.
BTL_Vector& operator/=(const value_type& y);
Vector division by a scalar and
assignment.
value_type Distance(const BTL_Vector& v) const;
Returns the root mean square distance
between this and BTL_Vector v.
unsigned int IsNotEqualTo(const BTL_Vector& v) const;
Returns zero if the cooresponding BTL_Vector
elements are all identical within the floating point
precision used. If they are not identical then the
function finds the largest difference between
cooresponding elements and outputs the number of
significant digits in this difference. The range this
number can take depends on the floating point precision
used. The maximum is typically equal to 6 for
single precision (FLT_DIG) and 15 for double precision
(DBL_DIG).
value_type Modulus() const;
Returns the modulus/magnitude of the
vector.
BTL_Matrix
BTL_Matrix();
Constructor for default 3x3 matrix and
initialise elements to zero.
BTL_Matrix(const size_type& s);
Constructs a unit matrix of size s*s.
BTL_Matrix(const size_type& p, const size_type& q);
Constructs a Matrix with p rows and q
columns. Initialises each element to zero
BTL_Matrix(const value_type * const array, const size_type& p, const size_type& q);
Constructs a Matrix with p rows and q
columns. Elements are initialised to those in array.
BTL_Matrix( const value_type& e1, const value_type& e2, const value_type& e3, const value_type& e4, const value_type& e5, const value_type& e6, const value_type& e7, const value_type& e8,const value_type& e9);
Constructor for a 3x3 Matrix with
initialisation
BTL_Matrix(const BTL_Vector& axis, const value_type& angle);
Constructor for 3x3 rotation matrix
for a rotation about a given axis by a given number of
degrees.
BTL_Matrix(const BTL_Matrix &m);
Copy constructor
~BTL_Matrix()
Destructor
BTL_Matrix& operator=(const BTL_Matrix &m);
Matrix assignment
value_type& operator()(const size_type& i, const size_type& j);
Read/write access a matrix element given its
indices
e.g. x(i,j) i = row, j = column. N.B. (i,j >= 1). (There
is also a const (read only) version of this function.)
value_type operator()(const size_type& i, const size_type& j) const;
iterator operator[](const size_type& i);
Returns an iterator that points the first
element of a given row. N.B. ( 0 <= i < nrows ). (There
is also a const (read only) version of this function.)
const_iterator operator[](const size_type& i) const;
BTL_Matrix operator*(const BTL_Matrix& m) const;
Matrix multiplication e.g. Matrix m1,m2,m3;
.... m3 = m1 * m2;
BTL_Vector operator*(const BTL_Vector &v) const;
Postmultiplication of a Matrix by a
BTL_Vector. e.g. Matrix m;
BTL_Vector v1,v2; ... v2 = m * v1;
Restrictions: The size of v must equal the number of
columns in this Matrix.
Friend: There exists a friend function: friend BTL_Vector
operator*(const BTL_Vector &v, const BTL_Matrix& m); that
performs premultiplication of BTL_Matrix by a BTL_Vector.
This method is slightly less efficient than
postmultiplication and requires that the size of
BTL_Vector v must equal the number of rows in
BTL_Matrix m.
BTL_Matrix& operator*=(const value_type& r);
Multiple each element by a number
BTL_Matrix operator*(const value_type& r) const;
Multiple each element by a number
Friend: The friend function: friend BTL_Matrix
operator*(const value_type& r, const BTL_Matrix& m); is
also available.
BTL_Matrix& operator/=(const value_type& r);
Divide each element by a number
BTL_Matrix operator/(const value_type& r) const;
Divide each element by a number
BTL_Matrix& operator-=(const value_type &v);
Subtraction of a number from each element.
BTL_Matrix operator-(const value_type &v) const;
Subtraction of a number from each element.
BTL_Matrix& operator+=(const value_type &v);
Addition of a number to each element.
BTL_Matrix operator+(const value_type &v) const;
Addition of a number to each element.
BTL_Matrix& operator-=(const BTL_Vector &v);
Subtraction of a vector from the rows
of a matrix
Restrictions: The the size of BTL_Vector v must equal the
number of columns in this BTL_Matrix.
BTL_Matrix operator-(const BTL_Vector &v) const;
Subtraction of a vector from the rows
of a matrix
Restrictions: The the size of BTL_Vector v must equal the
number of columns in this BTL_Matrix.
BTL_Matrix& operator+=(const BTL_Vector &v);
Addition of a vector to the rows
of a matrix
Restrictions: The the size of BTL_Vector v must equal the
number of columns in this BTL_Matrix.
BTL_Matrix operator+(const BTL_Vector &v) const;
Addition of a vector to the rows
of a matrix
Restrictions: The the size of BTL_Vector v must equal the
number of columns in this BTL_Matrix.
BTL_Matrix& operator-=(const BTL_Matrix &m);
BTL_Matrix subtraction
Restrictions: The the size of BTL_Matrix m must equal the
size of this BTL_Matrix.
BTL_Matrix operator-(const BTL_Matrix &m) const;
Matrix subtraction
Restrictions: The the size of Matrix m must equal the
size of this Matrix.
BTL_Matrix& operator+=(const BTL_Matrix &m);
Matrix addition
Restrictions: The the size of Matrix m must equal the
size of this Matrix.
BTL_Matrix operator+(const BTL_Matrix &m) const;
Matrix addition
Restrictions: The the size of Matrix m must equal the
size of this Matrix.
BTL_Matrix operator&(const BTL_Matrix& m) const;
Matrix multiplication Transpose(m1) * m2
N.B. this is less efficient than (but not equivalent to)
operator%
Restrictions: Both *this and the input Matrix must have
the same number of rows
BTL_Matrix operator%(const BTL_Matrix& m) const;
Matrix multiplication m1 * Transpose(m2)
N.B. this is more efficient than (but not equivalent to)
operator&
Restrictions: Both *this and the input Matrix must have
the same number of columns
bool operator==(const BTL_Matrix& m) const;
Equality operator
size_type lbound() const
This function is added to give
compatibility with TNT.
iterator begin()
Returns an iterator that points to the first
element in the Matrix. (There is also a const version of
this function.)
iterator end()
Returns an iterator that can be used
in a comparison for ending a traversal through this
Matrix. (There is also a const version of
this function.)
size_type size() const
Size of Matrix (the number of rows times
the number of columns)
BTL_Matrix Adjoint() const;
Matrix adjoint
Restrictions: Square matrices only
unsigned int IsNotEqualTo(const BTL_Matrix& m) const;
Returns zero if the cooresponding Matrix
elements are all identical within the floating point
precision used. If they are not identical then the
function finds the largest difference between
cooresponding elements and outputs the number of
significant digits in this difference. The range this
number can take depends on the floating point precision
used. The maximum is typically equal to 6 for
single precision (FLT_DIG) and 15 for double precision
(DBL_DIG).
BTL_Vector ColumnMean() const;
Calculate the mean of each column of this
Matrix and store the answer in a BTL_Vector
value_type Determinant() const;
Matrix determinant
Restrictions: Square matrices only.
void Eigens(BTL_Vector &eval, BTL_Matrix &evec) const;
Eigenvalues and eigenvectors of a symmetric
matrix
Restrictions: *this matrix must be square and
symmetric.
Parameters: (1) A returned vector with the same
dimension as *this Matrix (n) containing eigenvalues in
decreasing magnitude; (2) A returned Matrix of size n^2
containing eigenvectors stored columnwise in the same
order as the eigenvalues magnitude
void Inverse();
Matrix inverse. Answer overwrites this
Matrix.
value_type MaxDifference(const BTL_Matrix& m) const;
Find the largest difference between
elements of matrices of the same dimensions.
BTL_Matrix Minor(size_type i, size_type j) const;
Find the minor of a square matrix.
Restrictions: This matrix must be square.
size_type ReadNRows() const
Read number of rows.
size_type ReadNCols() const
Read number of columns.
size_type num_rows() const
Read number of rows (for compatability
with TNT).
size_type num_cols() const
Read number of columns (for compatability
with TNT).
size_type dim(size_type d) const
This function is added to give
compatibility with TNT.
BTL_Vector ReadRow(const size_type& rowIndx) const;
Copy a row of this Matrix into a BTL_Vector
BTL_Matrix SquareInverse() const;
Calculate inverse of a small square matrix
(inverse = adjoint/determinant).
void SVD(BTL_Vector& L, BTL_Matrix& V);
Single value decomposition.
Restrictions: On input, the size of BTL_Vector L must equal
the number of columns in this Matrix and Matrix V must
be a square Matrix with dimensions equal to the number of
columns in the input Matrix.
BTL_Matrix Transpose() const;
Matrix transpose
void WriteRow(const BTL_Vector& rowVector, const size_type& rowIndx);
Copy data from a BTL_Vector into a row of
this Matrix.
Restrictions: The size of the input BTL_Vector must
equal the number of columns in this Matrix.
void WriteRow(const value_type* rowArr, const size_type& rowIndx);
Copy data from an array into a row of
this Matrix. This routine assumes that the size of
the input array is equal the number of columns in this
Matrix.
BTL_CholeskyInverse
static void Invert(Matrix& m);
Invert the given matrix.
BTL_FFT
static void Transform(const RandomAccessIterator start, const RandomAccessIterator result, const unsigned int size, bool forward=true);
One dimensional FFT.
static void Transform(const RandomAccessIterator start, const RandomAccessIterator result, const unsigned int nrows, const unsigned int ncols, const bool forward=true);
Two dimensional FFT.
static void Transform(const RandomAccessIterator start, const RandomAccessIterator result, const unsigned int nrows, const unsigned int ncols, const unsigned int nlayers, const bool forward=true);
Three dimensional FFT.
BTL_Vertex
BTL_Vertex() : BTL_VertexBase()
Construct new empty Vertex
BTL_Vertex(const BTL_Vertex& v) : BTL_VertexBase(v)
Copy constructor.
virtual ~BTL_Vertex()
Destructor
iterator GetIterator()
Get an iterator that references the data
item associated with this vertex. With graphs that use STL
an vector or deque to store data items this iterator may become
invalid after insertions or deletions of vertices. (There is also a
const version of this function.)
const_iterator GetIterator() const
bool& Visited()
Read/write access to visited flag. This
can be used in Graph searching routines.
virtual VertexIterator begin_vertex()
Return iterator that references first
vertex connected to this vertex.(There is a
const version of this function as well)
virtual ConstVertexIterator begin_vertex() const
virtual VertexIterator end_vertex()
Return iterator that references the
position in memory after the last vertex connected to
this vertex.(There is a const version of this function
as well)
virtual ConstVertexIterator end_vertex() const
VertexIterator begin()
Return iterator that references first
vertex connected to this vertex. (There is a
const version of this function as well)
ConstVertexIterator begin() const
VertexIterator end()
Return iterator that references the
position in memory after the last vertex connected to
this vertex.(There is a const version of this function
as well)
ConstVertexIterator end() const
BTL_Graph
BTL_Graph()
Construct new undirected graph
BTL_Graph(const Directionality& e) : directionality(e)
Construct new undirected or
directed graph i.e. BTL_Graph g1(directed); or BTL_Graph
g2(undirected);
virtual ~BTL_Graph()
Delete Graph and all the vertices in it
Directionality GetDirectionality() const
Get the edge directionality of this
graph.
virtual VertexIterator AddVertex(const value_type& v)
Add new vertex to graph.
virtual bool RemoveVertex(VertexIterator in)
Remove a vertex (and all pointers to it)
from the graph. Return false if vertex was not found
in the graph.
bool AddLink(VertexIterator i1, VertexIterator i2)
Add a pointer between two vertices.
Return false if either vertex is not in this graph or
is link already present
bool RemoveLink(VertexIterator i1, VertexIterator i2)
Remove pointer/link between two vertices.
Return false if link not there
virtual void SetAllVisited(bool truth)
Set the visited field of all vertices in
this graph.
virtual VertexIterator find(Vertex& v)
Find a vertex within this Graph.(There is a
const version of this function as well)
virtual ConstVertexIterator find(Vertex& v) const
iterator begin()
Return iterator that references first
data item.(There is a const version of this function
as well)
iterator end()
Return iterator that references the
position in memory after the last data item. (There is a
const version of this function as well)
virtual VertexIterator begin_vertex()
Return iterator that references the first
Vertex. (There is a const version of this function
as well)
virtual ConstVertexIterator begin_vertex() const
virtual VertexIterator end_vertex()
Return iterator that references the
position in memory after the last Vertex. (There is a
const version of this function as well)
virtual ConstVertexIterator end_vertex() const
size_type size() const
Give the number of vertices within the
Graph
BTL_VertexWithEdges
BTL_VertexWithEdges() : Base()
Constructor empty vertex.
virtual ~BTL_VertexWithEdges()
Delete vertex and its contents.
EdgeIterator begin_edge()
Return iterator that references first
edge connected to Vertex. (There is also a const version
of this function.)
ConstEdgeIterator begin_edge() const
EdgeIterator end_edge()
Return iterator that references the
position in memory after the last edge connected to
Vertex. (There is also a const version
of this function.)
ConstEdgeIterator end_edge() const
BTL_Edge
BTL_Edge() : BTL_EdgeBase()
Construct empty edge
BTL_Edge(const BTL_Edge& e) : BTL_EdgeBase(e)
Copy constructor
virtual ~BTL_Edge()
Destructor
iterator GetIterator()
Returns an iterator that can be deferenced
to obtain the data object associated with this edge
(There is a const version of this function as well)
const_iterator GetIterator() const
VertexWEPtr LeftVertex() const
Returns pointer to the first vertex
connected to this edge.
VertexWEPtr RightVertex() const
Returns pointer to the second vertex
connected to this edge.
BTL_GraphWithEdges
BTL_GraphWithEdges() : Base()
Construct empty undirected graph.
BTL_GraphWithEdges(const Directionality& e) : Base(e)
Construct new undirected or
directed graph i.e.
BTL_GraphWithEdges g1(directed); or BTL_Graph
g2(undirected);
virtual ~BTL_GraphWithEdges()
Delete graph and all vertices and edges in
it.
virtual VertexIterator AddVertex(const value_type& v)
Add new vertex to graph.
virtual bool RemoveVertex(VertexIterator in)
Delete vertex from graph. Return false
if vertex not found in this graph.
EdgeIterator AddEdge(VertexIterator i1, VertexIterator i2, const EdgeData& d)
Insert edge into this graph. Return
endEdge() if input is invalid.
bool RemoveEdge(EdgeIterator edgeIter)
Remove edge from this graph. Return
false if input is invalid.
EdgeDataIterator BeginEdgeData()
Return iterator that references first
edge data item. (There is a const version of this
function as well)
EdgeDataConstIterator BeginEdgeData() const
EdgeDataIterator EndEdgeData()
Return iterator that references the
position in memory after the last edge data item.
(There is a const version of this function as well)
EdgeDataConstIterator EndEdgeData() const
EdgeIterator begin_edge()
Return EdgeIterator that references first
edge in graph. (There is a const version of this function
as well)
ConstEdgeIterator begin_edge() const
EdgeIterator end_edge()
Return EdgeIterator that references the
position in memory after the last edge in graph.(There
is a const version of this function as well)
ConstEdgeIterator end_edge() const
BTL_DFSIterator
BTL_DFSIterator()
Default constructor.
BTL_DFSIterator(const iterator& i)
Construct with iterator. This is essential
if operator++ etc. is to be used.
BTL_DFSIterator& operator++()
Move iterator forward one in depth first
search order.
bool operator!() const
Returns false when current position is one
past the end of the last element in the container.
BTL_DFSIterator operator++(int)
Move iterator forward one in depth first
search order.
bool operator==(BTL_DFSIterator i) const
Equality operator
value_type& operator*()
Dereference operator
BTL_ConstDFSIterator
BTL_ConstDFSIterator()
Default constructor.
BTL_ConstDFSIterator(const iterator& i)
Construct with iterator. This is essential
if operator++ etc. is to be used.
BTL_ConstDFSIterator& operator++()
Move iterator forward one in depth first
search order.
bool operator!() const
Returns false when current position is one
past the end of the last element in the container.
BTL_ConstDFSIterator operator++(int)
Move iterator forward one in depth first
search order.
bool operator==(BTL_ConstDFSIterator i) const
Equality operator
value_type operator*() const
Dereference operator
BTL_LeastSquaresFit
static BTL_REAL RMSD(ConstForwardIterator begin1, ConstForwardIterator end1, ConstForwardIterator begin2, ConstForwardIterator end2, const unsigned int nDimensions);
Calculate the root mean squared deviation
of two sets of coordinates.
Restrictions: Each set must have the same number of
coordinates. There is no restriction on the number of
dimensions which the coordinates represent (except that
it must be the same in every case). WARNING: if
coordinates with varying dimensions are input then this
may well not be detected.
static BTL_REAL Compare(ConstForwardIterator begin1, ConstForwardIterator end1, ConstForwardIterator begin2, ConstForwardIterator end2);
Calculate the root mean squared deviation
after a least squares fit of the two sets of coordinates
using the method of Kearsley. Both sets of coordinates
remain unchanged by this function
Restrictions: Each set must have the same number of
coordinates. Each coordinate must be orthogonal and in
three dimensions (i.e. normal x,y,z coordinates).
WARNING: if coordinates with varying dimensions are input
then this may well not be detected.
static BTL_REAL Fit(ForwardIterator begin1, ForwardIterator end1, ConstForwardIterator begin2, ConstForwardIterator end2);
Least squares fit one set of coordinates to
another using the method of Kearsley. Return the root
mean squared deviation after the fit. The second set of
coordinates remains unaltered by this function.
Restrictions: Each set must have the same number of
coordinates. Each coordinate must be orthogonal and in
three dimensions (i.e. normal x,y,z coordinates).
WARNING: if coordinates with varying dimensions are input
then this may well not be detected.
BTL_PDBSort
bool operator()(const string& atomId1, const string& atomId2) const;
Returns true is 1st string comes before
the 2nd in pdb order. Returns false otherwise
bool operator()(const char* atomId1, const char* atomId2) const;
The c style string version of the above
function
BTL_AminoAcidProperty
BTL_AminoAcidProperty();
Default constructor. The default property
type is KyteHydropathy.
BTL_AminoAcidProperty(const BTL_Scale whatScale);
Construct function object which will return
property values of a given type.
float operator()(const char aacode) const;
Operator that will return a property value
given a single letter amino acid code.
BTL_NumericLimits
static T epsilon()
Returns the value of the difference between 1
and the least value greater than 1 that is representable.
static T min()
Returns the minimum finite value.
static int digits10()
Returns the number of base 10 digits which can
be represented without change
BTL_NumericUtilities
static int PowerOf10(const T& x);
Returns i where x = n * 10^i and 10>n>0
static unsigned int AreNotEqual(const T& a, const T& b);
Finds the difference between two real numbers - the
outputed result is the number of digits after the decimal point of
the difference divided by the smallest detectable difference. The
output is zero if the difference was smaller than the smallest
detectable difference. The maximum output depends on the precision of
the input numbers e.g for two float numbers the maximum might be 6
(FLT_DIG) and for double's it might be 15 (DBL_DIG).
BTL_XYZProcessor
BTL_XYZProcessor()
Default constructor (does nothing)
bool empty() const
Returns true if no coordinates have been read
void ReadFile(const char *fileName);
Read an xyz format file with the given name
CoordStore& Coords()
Return a reference to the read coordinates in a
STL vector of float. Coordinates are stored in the following
order: x,y,z,x,y,z,x,...
ElementStore& Elements()
Return a reference to the read atomic elements in a
STL vector of char. Each element is stored as 2 chars.
BTL_PIRProcessor
BTL_PIRProcessor()
Default constructor (does nothing)
bool empty() const
Return true if no sequences have been
read in, false otherwise.
void ReadFile(const char *fileName);
Read a file with a given name. If this
function is called more than once, the new sequences
are added to those already there.
vector
Return any sequences that been read in.
string& Seq(const unsigned int iseq)
Return a single sequence, given a valid
index number
BTL_PPMProcessor
void ReadFile(const char *fileName);
Read in a file with a given name.
vector
Get image data.
void WriteImageData(const vector
Write image data.
unsigned int ReadWidth() const
Read width of image.
unsigned int ReadHeight() const
Read image height.
Questions or comments are welcome, please send them to
Will Pitt.