| 1 |
/* |
| 2 |
* Copyright (c) 2003 Philippe Grandclement |
| 3 |
* |
| 4 |
* This file is part of LORENE. |
| 5 |
* |
| 6 |
* LORENE is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License version 2 |
| 8 |
* as published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* LORENE is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with LORENE; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
char ope_vorton_cl_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_vorton/ope_vorton_cl.C,v 1.4 2014/10/13 08:53:36 j_novak Exp $" ; |
| 22 |
|
| 23 |
/* |
| 24 |
* $Id: ope_vorton_cl.C,v 1.4 2014/10/13 08:53:36 j_novak Exp $ |
| 25 |
* $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_vorton/ope_vorton_cl.C,v 1.4 2014/10/13 08:53:36 j_novak Exp $ |
| 26 |
* |
| 27 |
*/ |
| 28 |
#include <cmath> |
| 29 |
#include <cstdlib> |
| 30 |
|
| 31 |
#include "proto.h" |
| 32 |
#include "ope_elementary.h" |
| 33 |
|
| 34 |
// Version Matrice --> Matrice |
| 35 |
|
| 36 |
//------------------- |
| 37 |
//-- Pas prevu ---- |
| 38 |
//------------------- |
| 39 |
|
| 40 |
namespace Lorene { |
| 41 |
Matrice _cl_vorton_pas_prevu (const Matrice& so, int) { |
| 42 |
cout << "CL vorton not implemented" << endl ; |
| 43 |
abort() ; |
| 44 |
exit(-1) ; |
| 45 |
return so; |
| 46 |
} |
| 47 |
|
| 48 |
//------------------- |
| 49 |
//-- R_CHEB ------ |
| 50 |
//------------------- |
| 51 |
|
| 52 |
Matrice _cl_vorton_r_cheb (const Matrice& source, int) { |
| 53 |
|
| 54 |
int n = source.get_dim(0) ; |
| 55 |
assert (n==source.get_dim(1)) ; |
| 56 |
|
| 57 |
Matrice barre(source) ; |
| 58 |
int dirac = 1 ; |
| 59 |
for (int i=0 ; i<n-2 ; i++) { |
| 60 |
for (int j=0 ; j<n ; j++) |
| 61 |
barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) |
| 62 |
/(i+1) ; |
| 63 |
if (i==0) dirac = 0 ; |
| 64 |
} |
| 65 |
|
| 66 |
Matrice res(barre) ; |
| 67 |
for (int i=0 ; i<n-4 ; i++) |
| 68 |
for (int j=0 ; j< n ; j++) |
| 69 |
res.set(i, j) = barre(i, j)-barre(i+2, j) ; |
| 70 |
return res ; |
| 71 |
} |
| 72 |
|
| 73 |
//------------------- |
| 74 |
//-- R_CHEBU ----- |
| 75 |
//------------------- |
| 76 |
|
| 77 |
Matrice _cl_vorton_r_chebu_trois (const Matrice &source) { |
| 78 |
|
| 79 |
int n = source.get_dim(0) ; |
| 80 |
assert (n == source.get_dim(1)) ; |
| 81 |
|
| 82 |
Matrice barre(source) ; |
| 83 |
int dirac = 1 ; |
| 84 |
for (int i=0 ; i<n-2 ; i++) { |
| 85 |
for (int j=0 ; j<n ; j++) |
| 86 |
barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ; |
| 87 |
if (i==0) dirac = 0 ; |
| 88 |
} |
| 89 |
|
| 90 |
Matrice tilde(barre) ; |
| 91 |
for (int i=0 ; i<n-4 ; i++) |
| 92 |
for (int j=0 ; j<n ; j++) |
| 93 |
tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ; |
| 94 |
|
| 95 |
Matrice res(tilde) ; |
| 96 |
for (int i=0 ; i<n-4 ; i++) |
| 97 |
for (int j=0 ; j<n ; j++) |
| 98 |
res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ; |
| 99 |
|
| 100 |
return res ; |
| 101 |
} |
| 102 |
|
| 103 |
Matrice _cl_vorton_r_chebu (const Matrice &source, int puis) { |
| 104 |
int n = source.get_dim(0) ; |
| 105 |
assert (n == source.get_dim(1)) ; |
| 106 |
|
| 107 |
Matrice res(n, n) ; |
| 108 |
res.set_etat_qcq() ; |
| 109 |
|
| 110 |
switch (puis) { |
| 111 |
case 3 : |
| 112 |
res = _cl_vorton_r_chebu_trois(source) ; |
| 113 |
break ; |
| 114 |
default : |
| 115 |
abort() ; |
| 116 |
exit(-1) ; |
| 117 |
} |
| 118 |
return res ; |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
void Ope_vorton::do_ope_cl() const { |
| 123 |
if (ope_mat == 0x0) |
| 124 |
do_ope_mat() ; |
| 125 |
|
| 126 |
if (ope_cl != 0x0) |
| 127 |
delete ope_cl ; |
| 128 |
|
| 129 |
// Routines de derivation |
| 130 |
static Matrice (*cl_vorton[MAX_BASE])(const Matrice&, int); |
| 131 |
static int nap = 0 ; |
| 132 |
|
| 133 |
// Premier appel |
| 134 |
if (nap==0) { |
| 135 |
nap = 1 ; |
| 136 |
for (int i=0 ; i<MAX_BASE ; i++) { |
| 137 |
cl_vorton[i] = _cl_vorton_pas_prevu ; |
| 138 |
} |
| 139 |
// Les routines existantes |
| 140 |
cl_vorton[R_CHEB >> TRA_R] = _cl_vorton_r_cheb ; |
| 141 |
cl_vorton[R_CHEBU >> TRA_R] = _cl_vorton_r_chebu ; |
| 142 |
} |
| 143 |
ope_cl = new Matrice(cl_vorton[base_r](*ope_mat, dzpuis)) ; |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
} |