MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

tricoef.h
1 //
2 // tricoef.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit 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 Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27
28 #ifndef _math_isosurf_tricoef_h
29 #define _math_isosurf_tricoef_h
30
31 #ifdef __GNUC__
32 #pragma interface
33 #endif
34
35 #include <util/ref/ref.h>
36
37 namespace sc {
38
39 class TriInterpCoefKey {
40 private:
41 int order_;
42 double L2_;
43 double L3_;
44 public:
45 TriInterpCoefKey(int order, double L2, double L3):
46 order_(order), L2_(L2), L3_(L3) {}
47 int order() const { return order_; }
48 double L1() const { return 1.0 - L2_ - L3_; }
49 double L2() const { return L2_; }
50 double L3() const { return L3_; }
51 int cmp(const TriInterpCoefKey&t) const {
52 if (order_ < t.order_) return -1;
53 if (order_ > t.order_) return 1;
54 if (L2_ < t.L2_) return -1;
55 if (L2_ > t.L2_) return 1;
56 if (L3_ < t.L3_) return -1;
57 if (L3_ > t.L3_) return 1;
58 return 0;
59 }
60 };
61
62 #define TriInterpCoefKeyEQ(k1,k2) ((k1).cmp(k2)==0)
63 #define TriInterpCoefKeyCMP(k1,k2) ((k1).cmp(k2))
64
65 class TriInterpCoef: public RefCount {
66 double *coef_;
67 double *rderiv_;
68 double *sderiv_;
69 public:
70 TriInterpCoef(const TriInterpCoefKey& key);
71 ~TriInterpCoef();
72 double& coef(int i, int j, int k) {return coef_[ijk_to_index(i,j,k)];}
73 double& rderiv(int i, int j, int k) {return rderiv_[ijk_to_index(i,j,k)];}
74 double& sderiv(int i, int j, int k) {return sderiv_[ijk_to_index(i,j,k)];}
75
76 static int
77 ijk_to_index(int i, int j, int k)
78 {
79 int n = i + j + k;
80 int ir = n - i;
81 return (ir*(ir+1)>>1) + j;
82 }
83
84 static int
85 order_to_nvertex(int order)
86 {
87 return ((order+1)*(order+2)>>1);
88 }
89 };
90
91 }
92
93 #endif
94
95 // Local Variables:
96 // mode: c++
97 // c-file-style: "CLJ"
98 // End: