MET - Matrix Expression Templates

## Goals of MET

> C++ matrix and vector libraries make the scientific/engineering programming easier than legacy Fortran. Overloaded operators allow to write linear algebraic expressions as what you see in a text book like u = m*v + w in C++, instead of boring loops in fortran or C. This advantage, however, came with a performance penalty until recently. Due to the overhead of temporaries and copying of matrix objects, C++ lagged behind fortran's performance by an order of magnitude.

> A technique called expression templates is a way to make C++ codes faster but keep the advantages of object-oriented programming. Unfortunately, I have not found any ordinary matrix library with that technique implemented, though its effectiveness was already proved in various array libraries, Blitz++,POOMA, PETE. That is why I decided to make MET open-source.

### Features

> The Matrix Expression Templates library is,

- Generic :

Diagonal, square, rectangle matrix and vector classes are available. Their element type can be generic, so you can deal with integer, double precision and various complex types.

- Simple and Easy to use :

Your codes become simpler with overloaded operators, +, -, *, / , among the scalar, vector and matrix, but you need not take care of the implementation of expression templates.

- Portable :

MET is written in ANSI C++.

## Latest Release

> ## can be downloaded here.

## Installation

> Makefile is prepared for GNU make and C++ compiler (gcc 2.95.2). Expand gziped tar file and just type,

> `cd met/`
> `make`

## Getting Started

> Let's start with a simple example. Consider `u = m*v + w`, where `u,v` and `w` are vectors and `m` is matrix.

`const int size = 3;`
`Vec<double> u(size), v(size), w(size); //` the element type is double precision.
`Mat<double> m(size); //` 3x3 square matrix

`v(0) = 1; v(1) = 3; v(2) = 5; //` access to the vector element
`w = v;`

`m(0,0) = 2; m(0,1) = 3; m(0,2) = 4; //` access to the matrix element
`//` set the rest of elements as you like.

`u = m * v + w;`

`cout << "Answer is (";`
`for (int i=0; i<size; i++) cout << " " << u(i);`
`cout << " ) ." << endl;`

# Why expression templates?

> A native implementation would introduce temporary vectors for `m*v` and `m*v + w` and copies the result of `m*v` and `m*v + w` . But a smart library with expression templates introduce no temporaries, copies no objects, and touches each element of the matrix the minimum number of times.

> Detailed explanation of the technique and the outstanding results that C++ can rival to Fortan are shown in Blitz++ web site.

## Copyright & Disclaimer

Copyright © 2001 Masakatsu Ito. All Rights Reserved. mailto: masakatsu@users.sourceforge.net

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

> ##

## To Do

> - Add the interfaces to LAPACK library.

If you would like to help to develop MET, please mail to me or visit the project summary page for this project.

© 2001, Copyright by Masakatsu Ito; All Rights Reserved. mailto:masakatsu@users.sourceforge.net

This site is hosted by