blitz Version 0.10
blitz/tvcross.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  * blitz/tvcross.h      Cross product of TinyVector<N,3>'s
00004  *
00005  * $Id: tvcross.h,v 1.5 2011/03/25 22:41:16 julianc Exp $
00006  *
00007  * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
00008  *
00009  * This file is a part of Blitz.
00010  *
00011  * Blitz is free software: you can redistribute it and/or modify 
00012  * it under the terms of the GNU Lesser General Public License
00013  * as published by the Free Software Foundation, either version 3
00014  * of the License, or (at your option) any later version.
00015  *
00016  * Blitz is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public 
00022  * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
00023  * 
00024  * Suggestions:          blitz-devel@lists.sourceforge.net
00025  * Bugs:                 blitz-support@lists.sourceforge.net    
00026  *
00027  * For more information, please see the Blitz++ Home Page:
00028  *    https://sourceforge.net/projects/blitz/
00029  *
00030  ***************************************************************************/
00031 
00032 #ifndef BZ_TVCROSS_H
00033 #define BZ_TVCROSS_H
00034 
00035 #ifndef BZ_TINYVEC_H
00036  #error <blitz/tvcross.h> must be included via <blitz/tinyvec.h>
00037 #endif
00038 
00039 BZ_NAMESPACE(blitz)
00040 
00041 /*
00042  * cross product.
00043  *
00044  * NEEDS_WORK: - cross product of two different vector types
00045  *             - cross product involving expressions
00046  */
00047 
00048 template<typename T_numtype>
00049 TinyVector<T_numtype,3> cross(const TinyVector<T_numtype,3>& x, 
00050     const TinyVector<T_numtype,3>& y)
00051 {
00052     return TinyVector<T_numtype,3>(x[1]*y[2] - y[1]*x[2],
00053         y[0]*x[2] - x[0]*y[2], x[0]*y[1] - y[0]*x[1]);
00054 }
00055 
00056 
00057 BZ_NAMESPACE_END
00058 
00059 #endif // BZ_TVCROSS_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines