blitz Version 1.0.2
Loading...
Searching...
No Matches
tvcross.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/tvcross.h Cross product of TinyVector<N,3>'s
4 *
5 * $Id$
6 *
7 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
8 *
9 * This file is a part of Blitz.
10 *
11 * Blitz is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation, either version 3
14 * of the License, or (at your option) any later version.
15 *
16 * Blitz is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
23 *
24 * Suggestions: blitz-devel@lists.sourceforge.net
25 * Bugs: blitz-support@lists.sourceforge.net
26 *
27 * For more information, please see the Blitz++ Home Page:
28 * https://sourceforge.net/projects/blitz/
29 *
30 ***************************************************************************/
31
32#ifndef BZ_TVCROSS_H
33#define BZ_TVCROSS_H
34
35#ifndef BZ_TINYVEC_H
36 #error <blitz/tvcross.h> must be included via <blitz/tinyvec.h>
37#endif
38
39namespace blitz {
40
41/*
42 * cross product.
43 *
44 * NEEDS_WORK: - cross product of two different vector types
45 * - cross product involving expressions
46 */
47
48template<typename T_numtype>
51{
52 return TinyVector<T_numtype,3>(x[1]*y[2] - y[1]*x[2],
53 y[0]*x[2] - x[0]*y[2], x[0]*y[1] - y[0]*x[1]);
54}
55
56
57}
58
59#endif // BZ_TVCROSS_H
The TinyVector class is a one-dimensional, fixed length vector that implements the blitz expression t...
Definition: tinyvec2.h:73
Definition: array-impl.h:66
TinyVector< T_numtype, 3 > cross(const TinyVector< T_numtype, 3 > &x, const TinyVector< T_numtype, 3 > &y)
Definition: tvcross.h:49