$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library 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 Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef LINEAR_ALGEBRA_HH 00026 #define LINEAR_ALGEBRA_HH 00027 00028 #include "algorithm/linearAlgebra.h" 00029 00030 namespace plb { 00031 00032 template<typename T> 00033 void gramSchmidt(Array<T,3> const& v1Unit, Array<T,3>& v2Unit, Array<T,3>& v3Unit) { 00034 Array<T,3> e1((T)1,T(),T()), e2(T(),(T)1,T()), e3(T(),T(),(T)1); 00035 T v11 = dot(v1Unit,e1), av11 = fabs(v11); 00036 T v12 = dot(v1Unit,e2), av12 = fabs(v12); 00037 T v13 = dot(v1Unit,e3), av13 = fabs(v13); 00038 00039 if (av11 > av12) { 00040 if (av11 > av13) { // e1 best aligned with v1Unit. 00041 v2Unit = e2 - v12*v1Unit; 00042 v3Unit = e3 - v13*v1Unit; 00043 } 00044 else { // e3 best aligned with v1Unit. 00045 v2Unit = e1 - v11*v1Unit; 00046 v3Unit = e2 - v12*v1Unit; 00047 } 00048 } 00049 else { // av12 >= av11 00050 if (av12 > av13) { // e2 best aligned with v1Unit. 00051 v2Unit = e1 - v11*v1Unit; 00052 v3Unit = e3 - v13*v1Unit; 00053 } 00054 else { // e3 best aligned with v1Unit. 00055 v2Unit = e1 - v11*v1Unit; 00056 v3Unit = e2 - v12*v1Unit; 00057 } 00058 } 00059 00060 v2Unit /= norm(v2Unit); 00061 v3Unit -= dot(v2Unit,v3Unit)*v2Unit; 00062 v3Unit /= norm(v3Unit); 00063 } 00064 00065 } // namespace plb 00066 00067 #endif // LINEAR_ALGEBRA_HH 00068
1.6.3
1.6.3