X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fcml%2Fmatrix%2Fmatrix_functions.h;fp=src%2Fcml%2Fmatrix%2Fmatrix_functions.h;h=cd2c92ab1e9a694a1e853223c3e132593ce8f033;hp=0000000000000000000000000000000000000000;hb=0fffd0097d7b496454413e57b398c903ecc252e4;hpb=79becf045222f385da5a1b9eb79081f6f5266c86 diff --git a/src/cml/matrix/matrix_functions.h b/src/cml/matrix/matrix_functions.h new file mode 100644 index 0000000..cd2c92a --- /dev/null +++ b/src/cml/matrix/matrix_functions.h @@ -0,0 +1,43 @@ +/* -*- C++ -*- ------------------------------------------------------------ + +Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/ + +The Configurable Math Library (CML) is distributed under the terms of the +Boost Software License, v1.0 (see cml/LICENSE for details). + + *-----------------------------------------------------------------------*/ +/** @file + * @brief + */ + +#ifndef matrix_functions_h +#define matrix_functions_h + +namespace cml { + +/** Set the given matrix to the identity matrix. + * + * This only makes sense for a square matrix, but no error will be + * signaled if the matrix is not square. + * + * @todo This should return a MatrixXpr to allow loop unrolling, as should + * the class method. + */ +template +inline matrix +identity(const matrix& m) +{ + typename matrix::temporary_type result; + + /* This is a no-op for fixed-size matrices: */ + cml::et::detail::Resize(result, m.size()); + result.identity(); + return result; +} + +} // namespace cml + +#endif + +// ------------------------------------------------------------------------- +// vim:ft=cpp