/usr/include/gmm/gmm_modified_gram_schmidt.h is in libgmm++-dev 4.2.1~beta1~svn4482~dfsg-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | /* -*- c++ -*- (enables emacs c++ mode) */
/*===========================================================================
Copyright (C) 2002-2012 Yves Renard
This file is a part of GETFEM++
Getfem++ is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version along with the GCC Runtime Library
Exception either version 3.1 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 Lesser General Public
License and GCC Runtime Library Exception for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, you may use this file as it is a part of a free
software library without restriction. Specifically, if other files
instantiate templates or use macros or inline functions from this file,
or you compile this file and link it with other files to produce an
executable, this file does not by itself cause the resulting executable
to be covered by the GNU Lesser General Public License. This exception
does not however invalidate any other reasons why the executable file
might be covered by the GNU Lesser General Public License.
===========================================================================*/
//===========================================================================
//
// Copyright (c) 1998-2001, University of Notre Dame. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the University of Notre Dame nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE TRUSTEES OF INDIANA UNIVERSITY AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES
// OF INDIANA UNIVERSITY AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//===========================================================================
/**@file gmm_modified_gram_schmidt.h
@author Andrew Lumsdaine <lums@osl.iu.edu>, Lie-Quan Lee <llee@osl.iu.edu>
@date October 13, 2002.
@brief Modified Gram-Schmidt orthogonalization
*/
#ifndef GMM_MODIFIED_GRAM_SCHMIDT_H
#define GMM_MODIFIED_GRAM_SCHMIDT_H
#include "gmm_kernel.h"
namespace gmm {
template <typename T>
class modified_gram_schmidt {
protected:
typedef dense_matrix<T> MAT;
MAT M;
public:
modified_gram_schmidt(int restart, size_t s) : M(s, restart+1) {}
typename linalg_traits<MAT>::const_sub_col_type
operator[](size_t i) const { return mat_const_col(M, i); }
typename linalg_traits<MAT>::sub_col_type
operator[](size_t i) { return mat_col(M, i); }
inline size_type nrows(void) const { return M.nrows(); }
inline size_type ncols(void) const { return M.ncols(); }
MAT &mat(void) { return M; }
const MAT &mat(void) const { return M; }
};
template <typename T, typename VecHi> inline
void orthogonalize(modified_gram_schmidt<T>& V, const VecHi& Hi_, size_t i) {
VecHi& Hi = const_cast<VecHi&>(Hi_);
for (size_t k = 0; k <= i; k++) {
Hi[k] = gmm::vect_hp(V[i+1], V[k]);
gmm::add(gmm::scaled(V[k], -Hi[k]), V[i+1]);
}
}
template <typename T, typename VecHi>
void orthogonalize_with_refinment(modified_gram_schmidt<T>& V,
const VecHi& Hi_, size_t i) {
VecHi& Hi = const_cast<VecHi&>(Hi_);
orthogonalize(V, Hi_, i);
sub_interval SUBI(0, V.nrows()), SUBJ(0, i+1);
std::vector<T> corr(i+1);
gmm::mult(conjugated(sub_matrix(V.mat(), SUBI, SUBJ)),
V[i+1], corr);
gmm::mult(sub_matrix(V.mat(), SUBI, SUBJ),
scaled(corr, T(-1)), V[i+1],V[i+1]);
gmm::add(corr, sub_vector(Hi, SUBJ));
}
template <typename T, typename VecS, typename VecX>
void combine(modified_gram_schmidt<T>& V, const VecS& s, VecX& x, size_t i)
{ for (size_t j = 0; j < i; ++j) gmm::add(gmm::scaled(V[j], s[j]), x); }
}
#endif
|