EPFLSTILOBMarcel LeuteneggerAbout

MATLAB toolbox

Vector functions

MATLAB toolbox

Data types

Double class
Extended class
Single class


Flex99-12C correlator
Flex02-0xD correlator
Vector functions


C-MEX wrapper
FPU instructions


Error function
Hankel transform


The MATLAB toolbox offers two particular functions working on vectors as the vector cross product and the dot product. These functions are implemented to work on a general matrix dimension. Unfortunately, this implies a long overhead and slows down the performance significantly.

This archive offers some particular vector functions as the vector norm, the vector length, scaling and the cross respectively dot product. All functions work on the first dimension of [3xM] matrices.



Unpack the archive in a folder that is part of the MATLAB path. The subfolder '@class' contains the extension libraries.

If you unpack the source code, the subfolder 'source' contains all necessary C and assembler files. Each function splits in a C-MEX wrapper part to be translated with MATLAB:

   mex [-inline] [-O] func.c ffunc.obj [fdim.obj]

The underlying assembler functions are written in the Netwide Assembler syntax. It is freely available on the Internet. The command is:

   nasmw -f win32 ffunc.asm

Each function comes with an equivalent MATLAB script that also provides the command line help.


The libraries should always reside in a subfolder called '@class' to make sure they are not called for any data except of type class. They do not check the data type of passed arguments.

You may consult the C-MEX wrapper performance hints respectively the floating-point assembler hints.


These routines are published as freeware. The author reserves the right to modify any of the contained files.

You are allowed to distribute this package as long as you deliver the entire, original package for free.

Path File Description
/ Readme.txt This manual
@class/ vabs.dll Vector length
vabs.m Help file
vadd.dll Vector addition
vadd.m Help file
vcross.dll Vector cross product
vcross.m Help file
vdot.dll Vector dot product
vdot.m Help file
vmul.dll Vector scaling
vmul.m Help file
vnorm.dll Vector norm
vnorm.m Help file

The source code is fully disclosed to serve as practical example and for personal use only. You are not allowed to distribute the source code but you may apply it for your personal issues.

Path File Description
/ CmexWrapper.txt C-MEX wrapper performance hints
FPUasmHints.txt Floating-point assembler hints
Readme.txt This manual
source/ fdim.asm Compare dimensions
fvabs.asm Vector length
fvadd.asm Vector addition
fvcross.asm Vector cross product
fvdot.asm Vector dot product
fvmul.asm Vector scaling
fvnorm.asm Vector norm
vabs.c Vector length
vabs.m Help file
vadd.c Vector addition
vadd.m Help file
vcross.c Vector cross product
vcross.m Help file
vdot.c Vector dot product
vdot.m Help file
vmul.c Vector scaling
vmul.m Help file
vnorm.c Vector norm
vnorm.m Help file


Any warranty is strictly refused. Don't rely on any financial or technical support in case of malfunction or damage.

Comments are welcome. I will try to track reported problems and fix bugs.


January 18, 2004

Initial release.

March 3, 2005

Service release. Bug fix of the scripts.

March 6, 2005

Initial extended precision release.

May 2, 2005

Service release. Version information included.

December 29, 2005

Initial single precision release and vadd included.


Downloading these files, you accept the copyright terms.


MATLAB is a registered trademark of The MathWorks, Inc. Pentium is a registered trademark of Intel Corporation. Other product or brand names are trademarks or registered trademarks of their respective holders.

© 2011 École Polytechnique Fédérale de Lausanne