Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_fn.h
Go to the documentation of this file.
1 /*
2 Copyright 2010-2011 Pierre SMARS (smars@yuntech.edu.tw)
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 2 of the License, or
6 (at your option) any later version.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #ifndef _VE_FN_H_
17 #define _VE_FN_H_
18 
19 // .NAME a_fn - a function unit
20 // .PORTABILITY : ansi C++
21 // .SECTION Author
22 // Pierre Smars
23 
24 #include "a_mat_c.h"
25 
26 #include <valarray>
27 #include <iostream>
28 
30 class a_fn
31 {
32 public:
33  a_fn(int nv = 1, double dmin = 1.e-5, double gmin = 1e-6);
34  virtual ~a_fn();
35 
36  void dmin(double dmin) {dmin_ = dmin;}
37  double dmin() {return dmin_;}
38  void gmin(double gmin) {gmin_ = gmin;}
39  double gmin() {return gmin_;}
40  int nv() {return nv_;}
41  a_mat_c * getX() {return x_;}
42  double getX(int ai) {return (*x_)(ai);}
43  void showX(std::ostream& o);
44  void setX(const a_mat_c&);
45  void setX(int ai, double val) {(*x_)(ai)=val;}
46  virtual double getF() = 0;
47  double getdF(int ai);
48  void getGrad(a_mat_c&);
49  void dx(int ai);
50  void newton(int ai);
51  void incr(double alpha,const a_mat_c& dir);
52  void minGold0(const a_mat_c& dir, double A1, double B1);
53  void minGold(const a_mat_c& dir);
54  void mingrad(); //steepest descent method
55  void minsyst(); //univariate method
56  bool minver(); //test de convergence sur le gradiant
57  void minDFP(); //Davidon-Fletcher-Powell Method
58 
59 protected:
60  int nv_;
63  double dmin_;//increment ~infinitesimal
64  double gmin_;//la norme du gradiant qui stoppe les iter
65 
66  void setx0() {*x0_ = *x_;}
67 
68 private:
69  void go(double alpha, const a_mat_c& dir);
70  double gF(double alpha, const a_mat_c& dir);
71 };
72 
73 
74 #endif
a function unit
Definition: a_fn.h:31
void minGold(const a_mat_c &dir)
Definition: a_fn.cxx:175
void showX(std::ostream &o)
Definition: a_fn.cxx:35
void gmin(double gmin)
Definition: a_fn.h:38
void setX(const a_mat_c &)
Definition: a_fn.cxx:47
virtual ~a_fn()
Definition: a_fn.cxx:30
void newton(int ai)
Definition: a_fn.cxx:79
bool minver()
Definition: a_fn.cxx:259
void dmin(double dmin)
Definition: a_fn.h:36
void incr(double alpha, const a_mat_c &dir)
Definition: a_fn.cxx:96
int nv_
Definition: a_fn.h:60
void dx(int ai)
Definition: a_fn.cxx:71
void setx0()
Definition: a_fn.h:66
void minsyst()
Definition: a_fn.cxx:240
void getGrad(a_mat_c &)
Definition: a_fn.cxx:65
double gmin_
Definition: a_fn.h:64
double getdF(int ai)
Definition: a_fn.cxx:53
void setX(int ai, double val)
Definition: a_fn.h:45
int nv()
Definition: a_fn.h:40
double dmin_
Definition: a_fn.h:63
a_mat_c * getX()
Definition: a_fn.h:41
double gmin()
Definition: a_fn.h:39
void minGold0(const a_mat_c &dir, double A1, double B1)
Definition: a_fn.cxx:119
a_mat_c * x_
Definition: a_fn.h:61
void mingrad()
Definition: a_fn.cxx:225
a_fn(int nv=1, double dmin=1.e-5, double gmin=1e-6)
Definition: a_fn.cxx:24
double dmin()
Definition: a_fn.h:37
double getX(int ai)
Definition: a_fn.h:42
virtual double getF()=0
a_mat_c * x0_
Definition: a_fn.h:62
void minDFP()
Definition: a_fn.cxx:282
a column matrix unit
Definition: a_mat_c.h:29
int val