mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024002: Overall code and build procedure refactoring -- automatic
Automatic upgrade of OCCT code by command "occt_upgrade . -nocdl": - WOK-generated header files from inc and sources from drv are moved to src - CDL files removed - All packages are converted to nocdlpack
This commit is contained in:
142
src/math/FILES
142
src/math/FILES
@@ -1,18 +1,132 @@
|
||||
math.cxx
|
||||
math.hxx
|
||||
math_Array1OfValueAndWeight.hxx
|
||||
math_BFGS.cxx
|
||||
math_BFGS.hxx
|
||||
math_BFGS.lxx
|
||||
math_BissecNewton.cxx
|
||||
math_BissecNewton.hxx
|
||||
math_BissecNewton.lxx
|
||||
math_BracketedRoot.cxx
|
||||
math_BracketedRoot.hxx
|
||||
math_BracketedRoot.lxx
|
||||
math_BracketMinimum.cxx
|
||||
math_BracketMinimum.hxx
|
||||
math_BracketMinimum.lxx
|
||||
math_BrentMinimum.cxx
|
||||
math_BrentMinimum.hxx
|
||||
math_BrentMinimum.lxx
|
||||
math_BullardGenerator.hxx
|
||||
math_ComputeGaussPointsAndWeights.cxx
|
||||
math_ComputeGaussPointsAndWeights.hxx
|
||||
math_ComputeKronrodPointsAndWeights.cxx
|
||||
math_ComputeKronrodPointsAndWeights.hxx
|
||||
math_Crout.cxx
|
||||
math_Crout.hxx
|
||||
math_Crout.lxx
|
||||
math_DirectPolynomialRoots.cxx
|
||||
math_DirectPolynomialRoots.hxx
|
||||
math_DirectPolynomialRoots.lxx
|
||||
math_DoubleTab.cxx
|
||||
math_DoubleTab.hxx
|
||||
math_DoubleTab.lxx
|
||||
math_EigenValuesSearcher.cxx
|
||||
math_EigenValuesSearcher.hxx
|
||||
math_FRPR.cxx
|
||||
math_FRPR.hxx
|
||||
math_FRPR.lxx
|
||||
math_Function.cxx
|
||||
math_Function.hxx
|
||||
math_FunctionAllRoots.cxx
|
||||
math_FunctionAllRoots.hxx
|
||||
math_FunctionAllRoots.lxx
|
||||
math_FunctionRoot.cxx
|
||||
math_FunctionRoot.hxx
|
||||
math_FunctionRoot.lxx
|
||||
math_FunctionRoots.cxx
|
||||
math_FunctionRoots.hxx
|
||||
math_FunctionRoots.lxx
|
||||
math_FunctionSample.cxx
|
||||
math_FunctionSample.hxx
|
||||
math_FunctionSet.cxx
|
||||
math_FunctionSet.hxx
|
||||
math_FunctionSetRoot.cxx
|
||||
math_FunctionSetRoot.hxx
|
||||
math_FunctionSetRoot.lxx
|
||||
math_FunctionSetWithDerivatives.cxx
|
||||
math_FunctionSetWithDerivatives.hxx
|
||||
math_FunctionWithDerivative.cxx
|
||||
math_FunctionWithDerivative.hxx
|
||||
math_Gauss.cxx
|
||||
math_Gauss.hxx
|
||||
math_Gauss.lxx
|
||||
math_GaussLeastSquare.cxx
|
||||
math_GaussLeastSquare.hxx
|
||||
math_GaussLeastSquare.lxx
|
||||
math_GaussMultipleIntegration.cxx
|
||||
math_GaussMultipleIntegration.hxx
|
||||
math_GaussMultipleIntegration.lxx
|
||||
math_GaussPoints.hxx
|
||||
math_GaussSetIntegration.cxx
|
||||
math_GaussSetIntegration.hxx
|
||||
math_GaussSetIntegration.lxx
|
||||
math_GaussSingleIntegration.cxx
|
||||
math_GaussSingleIntegration.hxx
|
||||
math_GaussSingleIntegration.lxx
|
||||
math_GlobOptMin.cxx
|
||||
math_GlobOptMin.hxx
|
||||
math_Householder.cxx
|
||||
math_Householder.hxx
|
||||
math_Householder.lxx
|
||||
math_IntegerVector.cxx
|
||||
math_IntegerVector.hxx
|
||||
math_Jacobi.cxx
|
||||
math_Jacobi.hxx
|
||||
math_Jacobi.lxx
|
||||
math_Kronrod.cxx
|
||||
math_KronrodSingleIntegration.cxx
|
||||
math_KronrodSingleIntegration.hxx
|
||||
math_KronrodSingleIntegration.lxx
|
||||
math_Matrix.cxx
|
||||
math_Matrix.hxx
|
||||
math_Matrix.lxx
|
||||
math_MultipleVarFunction.cxx
|
||||
math_MultipleVarFunction.hxx
|
||||
math_MultipleVarFunctionWithGradient.cxx
|
||||
math_MultipleVarFunctionWithGradient.hxx
|
||||
math_MultipleVarFunctionWithHessian.cxx
|
||||
math_MultipleVarFunctionWithHessian.hxx
|
||||
math_NewtonFunctionRoot.cxx
|
||||
math_NewtonFunctionRoot.hxx
|
||||
math_NewtonFunctionRoot.lxx
|
||||
math_NewtonFunctionSetRoot.cxx
|
||||
math_NewtonFunctionSetRoot.hxx
|
||||
math_NewtonFunctionSetRoot.lxx
|
||||
math_NewtonMinimum.cxx
|
||||
math_NewtonMinimum.hxx
|
||||
math_NewtonMinimum.lxx
|
||||
math_NotSquare.hxx
|
||||
math_Powell.cxx
|
||||
math_Powell.hxx
|
||||
math_Powell.lxx
|
||||
math_PSO.cxx
|
||||
math_PSO.hxx
|
||||
math_PSOParticlesPool.cxx
|
||||
math_PSOParticlesPool.hxx
|
||||
math_Recipes.cxx
|
||||
math_Recipes.hxx
|
||||
math_GaussPoints.hxx
|
||||
math_Kronrod.cxx
|
||||
math_Vector.hxx
|
||||
math_Vector.cxx
|
||||
math_IntegerVector.hxx
|
||||
math_IntegerVector.cxx
|
||||
math_SingleTab.hxx
|
||||
math_GlobOptMin.hxx
|
||||
math_GlobOptMin.cxx
|
||||
math_PSO.hxx
|
||||
math_PSO.cxx
|
||||
math_BullardGenerator.hxx
|
||||
math_PSOParticlesPool.hxx
|
||||
math_PSOParticlesPool.cxx
|
||||
math_Array1OfValueAndWeight.hxx
|
||||
math_SingularMatrix.hxx
|
||||
math_Status.hxx
|
||||
math_SVD.cxx
|
||||
math_SVD.hxx
|
||||
math_SVD.lxx
|
||||
math_TrigonometricFunctionRoots.cxx
|
||||
math_TrigonometricFunctionRoots.hxx
|
||||
math_TrigonometricFunctionRoots.lxx
|
||||
math_Uzawa.cxx
|
||||
math_Uzawa.hxx
|
||||
math_Uzawa.lxx
|
||||
math_ValueAndWeight.hxx
|
||||
math_Vector.cxx
|
||||
math_Vector.hxx
|
||||
|
@@ -1,143 +0,0 @@
|
||||
-- Created on: 1991-01-21
|
||||
-- Created by: Isabelle GRIGNON
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
-- Modified by PMN 29/02/96: GaussSetIntegration added
|
||||
-- Modified by PMN 03/05/96: NewtonMinimum added
|
||||
|
||||
|
||||
package math
|
||||
|
||||
uses StdFail, TColStd, TCollection, Standard
|
||||
|
||||
is
|
||||
|
||||
---Level : Public
|
||||
-- All methods of all classes of this package will be public.
|
||||
|
||||
|
||||
|
||||
enumeration Status is
|
||||
OK,
|
||||
TooManyIterations,
|
||||
FunctionError,
|
||||
DirectionSearchError,
|
||||
NotBracketed
|
||||
end Status;
|
||||
|
||||
exception NotSquare inherits DimensionError;
|
||||
exception SingularMatrix inherits Failure;
|
||||
|
||||
|
||||
imported Vector;
|
||||
imported IntegerVector;
|
||||
class Matrix;
|
||||
deferred class Function;
|
||||
deferred class FunctionWithDerivative;
|
||||
deferred class MultipleVarFunction;
|
||||
deferred class MultipleVarFunctionWithGradient;
|
||||
deferred class MultipleVarFunctionWithHessian;
|
||||
deferred class FunctionSet;
|
||||
deferred class FunctionSetWithDerivatives;
|
||||
imported GlobOptMin;
|
||||
imported PSO;
|
||||
imported PSOParticlesPool;
|
||||
imported BullardGenerator;
|
||||
class Gauss;
|
||||
class GaussLeastSquare;
|
||||
class SVD;
|
||||
class DirectPolynomialRoots;
|
||||
class FunctionRoots;
|
||||
class BissecNewton;
|
||||
class FunctionRoot;
|
||||
class NewtonFunctionRoot;
|
||||
class BracketedRoot;
|
||||
class FunctionSetRoot;
|
||||
class NewtonFunctionSetRoot;
|
||||
class BracketMinimum;
|
||||
class BrentMinimum;
|
||||
class Powell;
|
||||
class FRPR;
|
||||
class BFGS;
|
||||
class NewtonMinimum;
|
||||
class Jacobi;
|
||||
class GaussSingleIntegration;
|
||||
class GaussMultipleIntegration;
|
||||
class GaussSetIntegration;
|
||||
class FunctionSample;
|
||||
class FunctionAllRoots;
|
||||
class Householder;
|
||||
class Crout;
|
||||
class Uzawa;
|
||||
class TrigonometricFunctionRoots;
|
||||
class KronrodSingleIntegration; -- SKV: Kronrod method implementation.
|
||||
class EigenValuesSearcher; -- for Kronrod method
|
||||
class ComputeGaussPointsAndWeights;
|
||||
class ComputeKronrodPointsAndWeights;
|
||||
imported ValueAndWeight;
|
||||
imported Array1OfValueAndWeight;
|
||||
|
||||
class DoubleTab;
|
||||
|
||||
--- Gauss Points
|
||||
|
||||
GaussPointsMax returns Integer;
|
||||
|
||||
GaussPoints(Index : Integer; Points : out Vector from math);
|
||||
|
||||
GaussWeights(Index : Integer; Weights : out Vector from math);
|
||||
|
||||
-- Modified by skv - Wed Dec 7 15:32:31 2005 Kronrod method. Begin
|
||||
KronrodPointsMax returns Integer;
|
||||
---Purpose: Returns the maximal number of points for that the values
|
||||
-- are stored in the table. If the number is greater then
|
||||
-- KronrodPointsMax, the points will be computed.
|
||||
|
||||
OrderedGaussPointsAndWeights(Index : Integer;
|
||||
Points : out Vector from math;
|
||||
Weights : out Vector from math)
|
||||
---Purpose: Returns a vector of Gauss points and a vector of their weights.
|
||||
-- The difference with the
|
||||
-- method GaussPoints is the following:
|
||||
-- - the points are returned in increasing order.
|
||||
-- - if Index is greater then GaussPointsMax, the points are
|
||||
-- computed.
|
||||
-- Returns Standard_True if Index is positive, Points' and Weights'
|
||||
-- length is equal to Index, Points and Weights are successfully computed.
|
||||
returns Boolean from Standard;
|
||||
|
||||
KronrodPointsAndWeights(Index : Integer;
|
||||
Points : out Vector from math;
|
||||
Weights : out Vector from math)
|
||||
---Purpose: Returns a vector of Kronrod points and a vector of their
|
||||
-- weights for Gauss-Kronrod computation method.
|
||||
-- Index should be odd and greater then or equal to 3,
|
||||
-- as the number of Kronrod points is equal to 2*N + 1,
|
||||
-- where N is a number of Gauss points. Points and Weights should
|
||||
-- have the size equal to Index. Each even element of Points
|
||||
-- represents a Gauss point value of N-th Gauss quadrature.
|
||||
-- The values from Index equal to 3 to 123 are stored in a
|
||||
-- table (see the file math_Kronrod.cxx). If Index is greater,
|
||||
-- then points and weights will be computed. Returns Standard_True
|
||||
-- if Index is odd, it is equal to the size of Points and Weights
|
||||
-- and the computation of Points and Weights is performed successfully.
|
||||
-- Otherwise this method returns Standard_False.
|
||||
returns Boolean from Standard;
|
||||
|
||||
-- Modified by skv - Wed Dec 7 15:32:31 2005 Kronrod method. End
|
||||
|
||||
end math;
|
||||
|
||||
|
@@ -16,10 +16,10 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math.ixx>
|
||||
|
||||
#include <math.hxx>
|
||||
#include <math_ComputeGaussPointsAndWeights.hxx>
|
||||
|
||||
Standard_Integer math::GaussPointsMax()
|
||||
|
176
src/math/math.hxx
Normal file
176
src/math/math.hxx
Normal file
@@ -0,0 +1,176 @@
|
||||
// Created on: 1991-01-21
|
||||
// Created by: Isabelle GRIGNON
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_HeaderFile
|
||||
#define _math_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
class math_Matrix;
|
||||
class math_Function;
|
||||
class math_FunctionWithDerivative;
|
||||
class math_MultipleVarFunction;
|
||||
class math_MultipleVarFunctionWithGradient;
|
||||
class math_MultipleVarFunctionWithHessian;
|
||||
class math_FunctionSet;
|
||||
class math_FunctionSetWithDerivatives;
|
||||
class math_Gauss;
|
||||
class math_GaussLeastSquare;
|
||||
class math_SVD;
|
||||
class math_DirectPolynomialRoots;
|
||||
class math_FunctionRoots;
|
||||
class math_BissecNewton;
|
||||
class math_FunctionRoot;
|
||||
class math_NewtonFunctionRoot;
|
||||
class math_BracketedRoot;
|
||||
class math_FunctionSetRoot;
|
||||
class math_NewtonFunctionSetRoot;
|
||||
class math_BracketMinimum;
|
||||
class math_BrentMinimum;
|
||||
class math_Powell;
|
||||
class math_FRPR;
|
||||
class math_BFGS;
|
||||
class math_NewtonMinimum;
|
||||
class math_Jacobi;
|
||||
class math_GaussSingleIntegration;
|
||||
class math_GaussMultipleIntegration;
|
||||
class math_GaussSetIntegration;
|
||||
class math_FunctionSample;
|
||||
class math_FunctionAllRoots;
|
||||
class math_Householder;
|
||||
class math_Crout;
|
||||
class math_Uzawa;
|
||||
class math_TrigonometricFunctionRoots;
|
||||
class math_KronrodSingleIntegration;
|
||||
class math_EigenValuesSearcher;
|
||||
class math_ComputeGaussPointsAndWeights;
|
||||
class math_ComputeKronrodPointsAndWeights;
|
||||
class math_DoubleTab;
|
||||
|
||||
|
||||
|
||||
class math
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT static Standard_Integer GaussPointsMax();
|
||||
|
||||
Standard_EXPORT static void GaussPoints (const Standard_Integer Index, math_Vector& Points);
|
||||
|
||||
Standard_EXPORT static void GaussWeights (const Standard_Integer Index, math_Vector& Weights);
|
||||
|
||||
//! Returns the maximal number of points for that the values
|
||||
//! are stored in the table. If the number is greater then
|
||||
//! KronrodPointsMax, the points will be computed.
|
||||
Standard_EXPORT static Standard_Integer KronrodPointsMax();
|
||||
|
||||
//! Returns a vector of Gauss points and a vector of their weights.
|
||||
//! The difference with the
|
||||
//! method GaussPoints is the following:
|
||||
//! - the points are returned in increasing order.
|
||||
//! - if Index is greater then GaussPointsMax, the points are
|
||||
//! computed.
|
||||
//! Returns Standard_True if Index is positive, Points' and Weights'
|
||||
//! length is equal to Index, Points and Weights are successfully computed.
|
||||
Standard_EXPORT static Standard_Boolean OrderedGaussPointsAndWeights (const Standard_Integer Index, math_Vector& Points, math_Vector& Weights);
|
||||
|
||||
//! Returns a vector of Kronrod points and a vector of their
|
||||
//! weights for Gauss-Kronrod computation method.
|
||||
//! Index should be odd and greater then or equal to 3,
|
||||
//! as the number of Kronrod points is equal to 2*N + 1,
|
||||
//! where N is a number of Gauss points. Points and Weights should
|
||||
//! have the size equal to Index. Each even element of Points
|
||||
//! represents a Gauss point value of N-th Gauss quadrature.
|
||||
//! The values from Index equal to 3 to 123 are stored in a
|
||||
//! table (see the file math_Kronrod.cxx). If Index is greater,
|
||||
//! then points and weights will be computed. Returns Standard_True
|
||||
//! if Index is odd, it is equal to the size of Points and Weights
|
||||
//! and the computation of Points and Weights is performed successfully.
|
||||
//! Otherwise this method returns Standard_False.
|
||||
Standard_EXPORT static Standard_Boolean KronrodPointsAndWeights (const Standard_Integer Index, math_Vector& Points, math_Vector& Weights);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
friend class math_Matrix;
|
||||
friend class math_Function;
|
||||
friend class math_FunctionWithDerivative;
|
||||
friend class math_MultipleVarFunction;
|
||||
friend class math_MultipleVarFunctionWithGradient;
|
||||
friend class math_MultipleVarFunctionWithHessian;
|
||||
friend class math_FunctionSet;
|
||||
friend class math_FunctionSetWithDerivatives;
|
||||
friend class math_Gauss;
|
||||
friend class math_GaussLeastSquare;
|
||||
friend class math_SVD;
|
||||
friend class math_DirectPolynomialRoots;
|
||||
friend class math_FunctionRoots;
|
||||
friend class math_BissecNewton;
|
||||
friend class math_FunctionRoot;
|
||||
friend class math_NewtonFunctionRoot;
|
||||
friend class math_BracketedRoot;
|
||||
friend class math_FunctionSetRoot;
|
||||
friend class math_NewtonFunctionSetRoot;
|
||||
friend class math_BracketMinimum;
|
||||
friend class math_BrentMinimum;
|
||||
friend class math_Powell;
|
||||
friend class math_FRPR;
|
||||
friend class math_BFGS;
|
||||
friend class math_NewtonMinimum;
|
||||
friend class math_Jacobi;
|
||||
friend class math_GaussSingleIntegration;
|
||||
friend class math_GaussMultipleIntegration;
|
||||
friend class math_GaussSetIntegration;
|
||||
friend class math_FunctionSample;
|
||||
friend class math_FunctionAllRoots;
|
||||
friend class math_Householder;
|
||||
friend class math_Crout;
|
||||
friend class math_Uzawa;
|
||||
friend class math_TrigonometricFunctionRoots;
|
||||
friend class math_KronrodSingleIntegration;
|
||||
friend class math_EigenValuesSearcher;
|
||||
friend class math_ComputeGaussPointsAndWeights;
|
||||
friend class math_ComputeKronrodPointsAndWeights;
|
||||
friend class math_DoubleTab;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_HeaderFile
|
@@ -1,163 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class BFGS from math
|
||||
---Purpose:
|
||||
-- This class implements the Broyden-Fletcher-Goldfarb-Shanno variant of
|
||||
-- Davidson-Fletcher-Powell minimization algorithm of a function of
|
||||
-- multiple variables.Knowledge of the function's gradient is required.
|
||||
|
||||
uses Vector from math, Matrix from math,
|
||||
MultipleVarFunctionWithGradient from math,
|
||||
Status from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail,
|
||||
DimensionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(NbVariables: Integer;
|
||||
Tolerance: Real = 1.0e-8;
|
||||
NbIterations: Integer = 200;
|
||||
ZEPS: Real = 1.0e-12)
|
||||
---Purpose: Initializes the computation of the minimum of a function with
|
||||
-- NbVariables.
|
||||
-- Tolerance, ZEPS and NbIterations are described in the method Perform.
|
||||
-- Warning:
|
||||
-- A call to the Perform method must be made after this
|
||||
-- initialization to effectively compute the minimum of the
|
||||
-- function F.
|
||||
returns BFGS;
|
||||
|
||||
---C++: alias "Standard_EXPORT virtual ~math_BFGS();"
|
||||
|
||||
Perform(me: in out; F: in out MultipleVarFunctionWithGradient;
|
||||
StartingPoint: Vector)
|
||||
---Purpose: Given the starting point StartingPoint,
|
||||
-- minimization is done on the function F.
|
||||
-- The solution F = Fi is found when :
|
||||
-- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
|
||||
-- Tolerance, ZEPS and maximum number of iterations are given
|
||||
-- in the constructor.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
IsSolutionReached(me; F: in out MultipleVarFunctionWithGradient)
|
||||
---Purpose:
|
||||
-- This method is called at the end of each iteration to check if the
|
||||
-- solution is found.
|
||||
-- It can be redefined in a sub-class to implement a specific test to
|
||||
-- stop the iterations.
|
||||
|
||||
returns Boolean
|
||||
is virtual;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Location(me)
|
||||
---Purpose: returns the location vector of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Location(me; Loc: out Vector)
|
||||
---Purpose: outputs the location vector of the minimum in Loc.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
-- Exception DimensionError is raised if the range of Loc is not
|
||||
-- equal to the range of the StartingPoint.
|
||||
---C++: inline
|
||||
|
||||
raises DimensionError,
|
||||
NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Minimum(me)
|
||||
---Purpose: returns the value of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Gradient(me)
|
||||
---Purpose: Returns the gradient vector at the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Gradient(me; Grad: out Vector)
|
||||
---Purpose: Returns the value of the gradient vector at the minimum in Grad.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
-- Exception DimensionError is raised if the range of Grad is not
|
||||
-- equal to the range of the StartingPoint.
|
||||
---C++: inline
|
||||
raises DimensionError,
|
||||
NotDone
|
||||
is static;
|
||||
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: Returns the number of iterations really done in the
|
||||
-- calculation of the minimum.
|
||||
-- The exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
TheStatus: Status is protected;
|
||||
TheLocation: Vector is protected;
|
||||
TheGradient: Vector is protected;
|
||||
PreviousMinimum: Real is protected;
|
||||
TheMinimum: Real is protected;
|
||||
XTol: Real is protected;
|
||||
EPSZ: Real is protected;
|
||||
nbiter: Integer is protected;
|
||||
Itermax: Integer;
|
||||
|
||||
end BFGS;
|
@@ -16,15 +16,17 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_BFGS.ixx>
|
||||
|
||||
#include <math_BFGS.hxx>
|
||||
#include <math_BracketMinimum.hxx>
|
||||
#include <math_BrentMinimum.hxx>
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
#include <math_MultipleVarFunctionWithGradient.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_MultipleVarFunctionWithGradient.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
#define R 0.61803399
|
||||
#define C (1.0-R)
|
||||
|
142
src/math/math_BFGS.hxx
Normal file
142
src/math/math_BFGS.hxx
Normal file
@@ -0,0 +1,142 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_BFGS_HeaderFile
|
||||
#define _math_BFGS_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Status.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class Standard_DimensionError;
|
||||
class math_MultipleVarFunctionWithGradient;
|
||||
|
||||
|
||||
|
||||
//! This class implements the Broyden-Fletcher-Goldfarb-Shanno variant of
|
||||
//! Davidson-Fletcher-Powell minimization algorithm of a function of
|
||||
//! multiple variables.Knowledge of the function's gradient is required.
|
||||
class math_BFGS
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Initializes the computation of the minimum of a function with
|
||||
//! NbVariables.
|
||||
//! Tolerance, ZEPS and NbIterations are described in the method Perform.
|
||||
//! Warning:
|
||||
//! A call to the Perform method must be made after this
|
||||
//! initialization to effectively compute the minimum of the
|
||||
//! function F.
|
||||
Standard_EXPORT math_BFGS(const Standard_Integer NbVariables, const Standard_Real Tolerance = 1.0e-8, const Standard_Integer NbIterations = 200, const Standard_Real ZEPS = 1.0e-12);
|
||||
Standard_EXPORT virtual ~math_BFGS();
|
||||
|
||||
//! Given the starting point StartingPoint,
|
||||
//! minimization is done on the function F.
|
||||
//! The solution F = Fi is found when :
|
||||
//! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
|
||||
//! Tolerance, ZEPS and maximum number of iterations are given
|
||||
//! in the constructor.
|
||||
Standard_EXPORT void Perform (math_MultipleVarFunctionWithGradient& F, const math_Vector& StartingPoint);
|
||||
|
||||
|
||||
//! This method is called at the end of each iteration to check if the
|
||||
//! solution is found.
|
||||
//! It can be redefined in a sub-class to implement a specific test to
|
||||
//! stop the iterations.
|
||||
Standard_EXPORT virtual Standard_Boolean IsSolutionReached (math_MultipleVarFunctionWithGradient& F) const;
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the location vector of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
const math_Vector& Location() const;
|
||||
|
||||
//! outputs the location vector of the minimum in Loc.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
//! Exception DimensionError is raised if the range of Loc is not
|
||||
//! equal to the range of the StartingPoint.
|
||||
void Location (math_Vector& Loc) const;
|
||||
|
||||
//! returns the value of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Minimum() const;
|
||||
|
||||
//! Returns the gradient vector at the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
const math_Vector& Gradient() const;
|
||||
|
||||
//! Returns the value of the gradient vector at the minimum in Grad.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
//! Exception DimensionError is raised if the range of Grad is not
|
||||
//! equal to the range of the StartingPoint.
|
||||
void Gradient (math_Vector& Grad) const;
|
||||
|
||||
//! Returns the number of iterations really done in the
|
||||
//! calculation of the minimum.
|
||||
//! The exception NotDone is raised if the minimum was not found.
|
||||
Standard_Integer NbIterations() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
math_Status TheStatus;
|
||||
math_Vector TheLocation;
|
||||
math_Vector TheGradient;
|
||||
Standard_Real PreviousMinimum;
|
||||
Standard_Real TheMinimum;
|
||||
Standard_Real XTol;
|
||||
Standard_Real EPSZ;
|
||||
Standard_Integer nbiter;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Integer Itermax;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_BFGS.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_BFGS_HeaderFile
|
@@ -1,120 +0,0 @@
|
||||
-- Created on: 1991-03-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class BissecNewton from math
|
||||
---Purpose:
|
||||
-- This class implements a combination of Newton-Raphson and bissection
|
||||
-- methods to find the root of the function between two bounds.
|
||||
-- Knowledge of the derivative is required.
|
||||
|
||||
uses Vector from math,
|
||||
Matrix from math,
|
||||
FunctionWithDerivative from math,
|
||||
Status from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(theXTolerance: in Real) returns BissecNewton;
|
||||
---Purpose: Constructor.
|
||||
-- @param theXTolerance - algorithm tolerance.
|
||||
|
||||
Perform(me: in out; F: out FunctionWithDerivative;
|
||||
Bound1, Bound2: Real;
|
||||
NbIterations: Integer = 100)
|
||||
---Purpose:
|
||||
-- A combination of Newton-Raphson and bissection methods is done to find
|
||||
-- the root of the function F between the bounds Bound1 and Bound2
|
||||
-- on the function F.
|
||||
-- The tolerance required on the root is given by TolX.
|
||||
-- The solution is found when:
|
||||
-- abs(Xi - Xi-1) <= TolX and F(Xi) * F(Xi-1) <= 0
|
||||
-- The maximum number of iterations allowed is given by NbIterations.
|
||||
is static;
|
||||
|
||||
|
||||
IsSolutionReached(me: in out; theFunction: out FunctionWithDerivative)
|
||||
---Purpose:
|
||||
-- This method is called at the end of each iteration to check if the
|
||||
-- solution has been found.
|
||||
-- It can be redefined in a sub-class to implement a specific test to
|
||||
-- stop the iterations.
|
||||
---C++: inline
|
||||
returns Boolean is virtual;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Tests is the root has been successfully found.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Root(me)
|
||||
---Purpose: returns the value of the root.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
Derivative(me)
|
||||
---Purpose: returns the value of the derivative at the root.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns the value of the function at the root.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redifine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
Delete(me) is static;
|
||||
---Purpose: Destructor alias.
|
||||
---C++: inline
|
||||
---C++: alias " Standard_EXPORT virtual ~math_BissecNewton();"
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
TheStatus: Status is protected;
|
||||
XTol: Real is protected;
|
||||
x: Real is protected;
|
||||
dx: Real is protected;
|
||||
f: Real is protected;
|
||||
df: Real is protected;
|
||||
|
||||
end BissecNewton;
|
@@ -12,8 +12,10 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_BissecNewton.ixx>
|
||||
|
||||
#include <math_BissecNewton.hxx>
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : math_BissecNewton
|
||||
|
120
src/math/math_BissecNewton.hxx
Normal file
120
src/math/math_BissecNewton.hxx
Normal file
@@ -0,0 +1,120 @@
|
||||
// Created on: 1991-03-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_BissecNewton_HeaderFile
|
||||
#define _math_BissecNewton_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Status.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_FunctionWithDerivative;
|
||||
|
||||
|
||||
|
||||
//! This class implements a combination of Newton-Raphson and bissection
|
||||
//! methods to find the root of the function between two bounds.
|
||||
//! Knowledge of the derivative is required.
|
||||
class math_BissecNewton
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Constructor.
|
||||
//! @param theXTolerance - algorithm tolerance.
|
||||
Standard_EXPORT math_BissecNewton(const Standard_Real theXTolerance);
|
||||
|
||||
|
||||
//! A combination of Newton-Raphson and bissection methods is done to find
|
||||
//! the root of the function F between the bounds Bound1 and Bound2
|
||||
//! on the function F.
|
||||
//! The tolerance required on the root is given by TolX.
|
||||
//! The solution is found when:
|
||||
//! abs(Xi - Xi-1) <= TolX and F(Xi) * F(Xi-1) <= 0
|
||||
//! The maximum number of iterations allowed is given by NbIterations.
|
||||
Standard_EXPORT void Perform (math_FunctionWithDerivative& F, const Standard_Real Bound1, const Standard_Real Bound2, const Standard_Integer NbIterations = 100);
|
||||
|
||||
|
||||
//! This method is called at the end of each iteration to check if the
|
||||
//! solution has been found.
|
||||
//! It can be redefined in a sub-class to implement a specific test to
|
||||
//! stop the iterations.
|
||||
virtual Standard_Boolean IsSolutionReached (math_FunctionWithDerivative& theFunction);
|
||||
|
||||
//! Tests is the root has been successfully found.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the value of the root.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Root() const;
|
||||
|
||||
//! returns the value of the derivative at the root.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Derivative() const;
|
||||
|
||||
//! returns the value of the function at the root.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Value() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redifine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
//! Destructor alias.
|
||||
void Delete() const;
|
||||
Standard_EXPORT virtual ~math_BissecNewton();
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
math_Status TheStatus;
|
||||
Standard_Real XTol;
|
||||
Standard_Real x;
|
||||
Standard_Real dx;
|
||||
Standard_Real f;
|
||||
Standard_Real df;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_BissecNewton.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_BissecNewton_HeaderFile
|
@@ -1,118 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class BracketMinimum from math
|
||||
---Purpose:Given two distinct initial points, BracketMinimum
|
||||
-- implements the computation of three points (a, b, c) which
|
||||
-- bracket the minimum of the function and verify A less than
|
||||
-- B, B less than C and F(A) less than F(B), F(B) less than (C).
|
||||
uses Vector from math,
|
||||
Matrix from math,
|
||||
Function from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create(F: in out Function; A, B: Real)
|
||||
---Purpose:
|
||||
-- Given two initial values this class computes a
|
||||
-- bracketing triplet of abscissae Ax, Bx, Cx
|
||||
-- (such that Bx is between Ax and Cx, F(Bx) is
|
||||
-- less than both F(Bx) and F(Cx)) the Brent minimization is done
|
||||
-- on the function F.
|
||||
|
||||
returns BracketMinimum;
|
||||
|
||||
Create(F: in out Function; A, B, FA: Real)
|
||||
---Purpose:
|
||||
-- Given two initial values this class computes a
|
||||
-- bracketing triplet of abscissae Ax, Bx, Cx
|
||||
-- (such that Bx is between Ax and Cx, F(Bx) is
|
||||
-- less than both F(Bx) and F(Cx)) the Brent minimization is done
|
||||
-- on the function F.
|
||||
-- This constructor has to be used if F(A) is known.
|
||||
|
||||
returns BracketMinimum;
|
||||
|
||||
|
||||
Create(F: in out Function; A, B, FA, FB: Real)
|
||||
---Purpose:
|
||||
-- Given two initial values this class computes a
|
||||
-- bracketing triplet of abscissae Ax, Bx, Cx
|
||||
-- (such that Bx is between Ax and Cx, F(Bx) is
|
||||
-- less than both F(Bx) and F(Cx)) the Brent minimization is done
|
||||
-- on the function F.
|
||||
-- This constructor has to be used if F(A) and F(B) are known.
|
||||
|
||||
returns BracketMinimum;
|
||||
|
||||
|
||||
Perform(me: in out; F: in out Function; A, B: Real)
|
||||
---Purpose: Is used internally by the constructors.
|
||||
|
||||
is static protected;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Values(me; A, B, C: out Real)
|
||||
---Purpose: Returns the bracketed triplet of abscissae.
|
||||
-- Exceptions
|
||||
-- StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
FunctionValues(me; FA, FB, FC: out Real)
|
||||
---Purpose: returns the bracketed triplet function values.
|
||||
-- Exceptions
|
||||
-- StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
Ax: Real;
|
||||
Bx: Real;
|
||||
Cx: Real;
|
||||
FAx: Real;
|
||||
FBx: Real;
|
||||
FCx: Real;
|
||||
myFA: Boolean;
|
||||
myFB: Boolean;
|
||||
|
||||
end BracketMinimum;
|
@@ -12,11 +12,12 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_BracketMinimum.ixx>
|
||||
|
||||
#include <StdFail_NotDone.hxx> // waiting for NotDone Exception
|
||||
#include <math_BracketMinimum.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
// waiting for NotDone Exception
|
||||
#define GOLD 1.618034
|
||||
#define CGOLD 0.3819660
|
||||
#define GLIMIT 100.0
|
||||
|
122
src/math/math_BracketMinimum.hxx
Normal file
122
src/math/math_BracketMinimum.hxx
Normal file
@@ -0,0 +1,122 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_BracketMinimum_HeaderFile
|
||||
#define _math_BracketMinimum_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_Function;
|
||||
|
||||
|
||||
//! Given two distinct initial points, BracketMinimum
|
||||
//! implements the computation of three points (a, b, c) which
|
||||
//! bracket the minimum of the function and verify A less than
|
||||
//! B, B less than C and F(A) less than F(B), F(B) less than (C).
|
||||
class math_BracketMinimum
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! Given two initial values this class computes a
|
||||
//! bracketing triplet of abscissae Ax, Bx, Cx
|
||||
//! (such that Bx is between Ax and Cx, F(Bx) is
|
||||
//! less than both F(Bx) and F(Cx)) the Brent minimization is done
|
||||
//! on the function F.
|
||||
Standard_EXPORT math_BracketMinimum(math_Function& F, const Standard_Real A, const Standard_Real B);
|
||||
|
||||
|
||||
//! Given two initial values this class computes a
|
||||
//! bracketing triplet of abscissae Ax, Bx, Cx
|
||||
//! (such that Bx is between Ax and Cx, F(Bx) is
|
||||
//! less than both F(Bx) and F(Cx)) the Brent minimization is done
|
||||
//! on the function F.
|
||||
//! This constructor has to be used if F(A) is known.
|
||||
Standard_EXPORT math_BracketMinimum(math_Function& F, const Standard_Real A, const Standard_Real B, const Standard_Real FA);
|
||||
|
||||
|
||||
//! Given two initial values this class computes a
|
||||
//! bracketing triplet of abscissae Ax, Bx, Cx
|
||||
//! (such that Bx is between Ax and Cx, F(Bx) is
|
||||
//! less than both F(Bx) and F(Cx)) the Brent minimization is done
|
||||
//! on the function F.
|
||||
//! This constructor has to be used if F(A) and F(B) are known.
|
||||
Standard_EXPORT math_BracketMinimum(math_Function& F, const Standard_Real A, const Standard_Real B, const Standard_Real FA, const Standard_Real FB);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns the bracketed triplet of abscissae.
|
||||
//! Exceptions
|
||||
//! StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
Standard_EXPORT void Values (Standard_Real& A, Standard_Real& B, Standard_Real& C) const;
|
||||
|
||||
//! returns the bracketed triplet function values.
|
||||
//! Exceptions
|
||||
//! StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
Standard_EXPORT void FunctionValues (Standard_Real& FA, Standard_Real& FB, Standard_Real& FC) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//! Is used internally by the constructors.
|
||||
Standard_EXPORT void Perform (math_Function& F, const Standard_Real A, const Standard_Real B);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Real Ax;
|
||||
Standard_Real Bx;
|
||||
Standard_Real Cx;
|
||||
Standard_Real FAx;
|
||||
Standard_Real FBx;
|
||||
Standard_Real FCx;
|
||||
Standard_Boolean myFA;
|
||||
Standard_Boolean myFB;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_BracketMinimum.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_BracketMinimum_HeaderFile
|
@@ -1,94 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent Painnot
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class BracketedRoot from math
|
||||
---Purpose: This class implements the Brent method to find the root of a function
|
||||
-- located within two bounds. No knowledge of the derivative is required.
|
||||
|
||||
uses Matrix from math,
|
||||
Vector from math,
|
||||
Function from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out Function;
|
||||
Bound1, Bound2, Tolerance: Real;
|
||||
NbIterations: Integer = 100; ZEPS : Real =1.0e-12)
|
||||
---Purpose:
|
||||
-- The Brent method is used to find the root of the function F between
|
||||
-- the bounds Bound1 and Bound2 on the function F.
|
||||
-- If F(Bound1)*F(Bound2) >0 the Brent method fails.
|
||||
-- The tolerance required for the root is given by Tolerance.
|
||||
-- The solution is found when :
|
||||
-- abs(Xi - Xi-1) <= Tolerance;
|
||||
-- The maximum number of iterations allowed is given by NbIterations.
|
||||
|
||||
returns BracketedRoot;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Root(me)
|
||||
---Purpose: returns the value of the root.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns the value of the function at the root.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: returns the number of iterations really done during the
|
||||
-- computation of the Root.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
TheRoot: Real;
|
||||
TheError: Real;
|
||||
NbIter: Integer;
|
||||
|
||||
end BracketedRoot;
|
@@ -12,13 +12,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_BracketedRoot.ixx>
|
||||
|
||||
#include <math_BracketedRoot.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
// reference algorithme:
|
||||
// Brent method
|
||||
// numerical recipes in C p 269
|
||||
|
||||
math_BracketedRoot::math_BracketedRoot (math_Function& F,
|
||||
const Standard_Real Bound1,
|
||||
const Standard_Real Bound2,
|
||||
|
99
src/math/math_BracketedRoot.hxx
Normal file
99
src/math/math_BracketedRoot.hxx
Normal file
@@ -0,0 +1,99 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent Painnot
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_BracketedRoot_HeaderFile
|
||||
#define _math_BracketedRoot_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_Function;
|
||||
|
||||
|
||||
//! This class implements the Brent method to find the root of a function
|
||||
//! located within two bounds. No knowledge of the derivative is required.
|
||||
class math_BracketedRoot
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! The Brent method is used to find the root of the function F between
|
||||
//! the bounds Bound1 and Bound2 on the function F.
|
||||
//! If F(Bound1)*F(Bound2) >0 the Brent method fails.
|
||||
//! The tolerance required for the root is given by Tolerance.
|
||||
//! The solution is found when :
|
||||
//! abs(Xi - Xi-1) <= Tolerance;
|
||||
//! The maximum number of iterations allowed is given by NbIterations.
|
||||
Standard_EXPORT math_BracketedRoot(math_Function& F, const Standard_Real Bound1, const Standard_Real Bound2, const Standard_Real Tolerance, const Standard_Integer NbIterations = 100, const Standard_Real ZEPS = 1.0e-12);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the value of the root.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Root() const;
|
||||
|
||||
//! returns the value of the function at the root.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Value() const;
|
||||
|
||||
//! returns the number of iterations really done during the
|
||||
//! computation of the Root.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Integer NbIterations() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Real TheRoot;
|
||||
Standard_Real TheError;
|
||||
Standard_Integer NbIter;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_BracketedRoot.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_BracketedRoot_HeaderFile
|
@@ -1,138 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class BrentMinimum from math
|
||||
---Purpose:
|
||||
-- This class implements the Brent's method to find the minimum of
|
||||
-- a function of a single variable.
|
||||
-- No knowledge of the derivative is required.
|
||||
|
||||
uses Matrix from math,
|
||||
Vector from math,
|
||||
Function from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(TolX: Real;
|
||||
NbIterations: Integer = 100;
|
||||
ZEPS: Real = 1.0e-12)
|
||||
---Purpose:
|
||||
-- This constructor should be used in a sub-class to initialize
|
||||
-- correctly all the fields of this class.
|
||||
returns BrentMinimum;
|
||||
|
||||
|
||||
Create(TolX: Real; Fbx: Real;
|
||||
NbIterations: Integer = 100;
|
||||
ZEPS: Real = 1.0e-12)
|
||||
---Purpose:
|
||||
-- This constructor should be used in a sub-class to initialize
|
||||
-- correctly all the fields of this class.
|
||||
-- It has to be used if F(Bx) is known.
|
||||
returns BrentMinimum;
|
||||
|
||||
|
||||
Delete(me) is static;
|
||||
---Purpose: Destructor alias.
|
||||
---C++: inline
|
||||
---C++: alias " Standard_EXPORT virtual ~math_BrentMinimum();"
|
||||
|
||||
|
||||
Perform(me: in out; F: in out Function;
|
||||
Ax, Bx, Cx: Real)
|
||||
---Purpose:
|
||||
-- Brent minimization is performed on function F from a given
|
||||
-- bracketing triplet of abscissas Ax, Bx, Cx (such that Bx is
|
||||
-- between Ax and Cx, F(Bx) is less than both F(Bx) and F(Cx))
|
||||
-- The solution is found when: abs(Xi - Xi-1) <= TolX * abs(Xi) + ZEPS;
|
||||
is static;
|
||||
|
||||
|
||||
IsSolutionReached(me: in out; theFunction: in out Function)
|
||||
---Purpose:
|
||||
-- This method is called at the end of each iteration to check if the
|
||||
-- solution is found.
|
||||
-- It can be redefined in a sub-class to implement a specific test to
|
||||
-- stop the iterations.
|
||||
---C++:inline
|
||||
returns Boolean is virtual;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Location(me)
|
||||
---Purpose: returns the location value of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Minimum(me)
|
||||
---Purpose: returns the value of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: returns the number of iterations really done during the
|
||||
-- computation of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
a: Real is protected;
|
||||
b: Real is protected;
|
||||
x: Real is protected;
|
||||
fx: Real is protected;
|
||||
fv: Real is protected;
|
||||
fw: Real is protected;
|
||||
iter: Integer;
|
||||
XTol: Real is protected;
|
||||
EPSZ: Real is protected;
|
||||
Itermax: Integer;
|
||||
myF: Boolean;
|
||||
|
||||
end BrentMinimum;
|
@@ -12,8 +12,10 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_BrentMinimum.ixx>
|
||||
|
||||
#include <math_BrentMinimum.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
#define CGOLD 0.3819660
|
||||
#ifdef MAX
|
||||
|
129
src/math/math_BrentMinimum.hxx
Normal file
129
src/math/math_BrentMinimum.hxx
Normal file
@@ -0,0 +1,129 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_BrentMinimum_HeaderFile
|
||||
#define _math_BrentMinimum_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_Function;
|
||||
|
||||
|
||||
|
||||
//! This class implements the Brent's method to find the minimum of
|
||||
//! a function of a single variable.
|
||||
//! No knowledge of the derivative is required.
|
||||
class math_BrentMinimum
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! This constructor should be used in a sub-class to initialize
|
||||
//! correctly all the fields of this class.
|
||||
Standard_EXPORT math_BrentMinimum(const Standard_Real TolX, const Standard_Integer NbIterations = 100, const Standard_Real ZEPS = 1.0e-12);
|
||||
|
||||
|
||||
//! This constructor should be used in a sub-class to initialize
|
||||
//! correctly all the fields of this class.
|
||||
//! It has to be used if F(Bx) is known.
|
||||
Standard_EXPORT math_BrentMinimum(const Standard_Real TolX, const Standard_Real Fbx, const Standard_Integer NbIterations = 100, const Standard_Real ZEPS = 1.0e-12);
|
||||
|
||||
//! Destructor alias.
|
||||
void Delete() const;
|
||||
Standard_EXPORT virtual ~math_BrentMinimum();
|
||||
|
||||
|
||||
//! Brent minimization is performed on function F from a given
|
||||
//! bracketing triplet of abscissas Ax, Bx, Cx (such that Bx is
|
||||
//! between Ax and Cx, F(Bx) is less than both F(Bx) and F(Cx))
|
||||
//! The solution is found when: abs(Xi - Xi-1) <= TolX * abs(Xi) + ZEPS;
|
||||
Standard_EXPORT void Perform (math_Function& F, const Standard_Real Ax, const Standard_Real Bx, const Standard_Real Cx);
|
||||
|
||||
|
||||
//! This method is called at the end of each iteration to check if the
|
||||
//! solution is found.
|
||||
//! It can be redefined in a sub-class to implement a specific test to
|
||||
//! stop the iterations.
|
||||
virtual Standard_Boolean IsSolutionReached (math_Function& theFunction);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the location value of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Location() const;
|
||||
|
||||
//! returns the value of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Minimum() const;
|
||||
|
||||
//! returns the number of iterations really done during the
|
||||
//! computation of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Integer NbIterations() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
Standard_Real a;
|
||||
Standard_Real b;
|
||||
Standard_Real x;
|
||||
Standard_Real fx;
|
||||
Standard_Real fv;
|
||||
Standard_Real fw;
|
||||
Standard_Real XTol;
|
||||
Standard_Real EPSZ;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Integer iter;
|
||||
Standard_Integer Itermax;
|
||||
Standard_Boolean myF;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_BrentMinimum.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_BrentMinimum_HeaderFile
|
@@ -1,42 +0,0 @@
|
||||
-- Created on: 2005-12-19
|
||||
-- Created by: Julia GERASIMOVA
|
||||
-- Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class ComputeGaussPointsAndWeights from math
|
||||
|
||||
uses
|
||||
|
||||
Vector from math,
|
||||
HArray1OfReal from TColStd
|
||||
|
||||
is
|
||||
Create(Number : Integer from Standard)
|
||||
returns ComputeGaussPointsAndWeights;
|
||||
|
||||
IsDone(me)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Points(me)
|
||||
returns Vector from math;
|
||||
|
||||
Weights(me)
|
||||
returns Vector from math;
|
||||
|
||||
fields
|
||||
|
||||
myPoints : HArray1OfReal from TColStd;
|
||||
myWeights : HArray1OfReal from TColStd;
|
||||
myIsDone : Boolean from Standard;
|
||||
|
||||
end ComputeGaussPointsAndWeights;
|
@@ -13,14 +13,13 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_ComputeGaussPointsAndWeights.ixx>
|
||||
|
||||
#include <math_EigenValuesSearcher.hxx>
|
||||
#include <math_Array1OfValueAndWeight.hxx>
|
||||
#include <math_ComputeGaussPointsAndWeights.hxx>
|
||||
#include <math_EigenValuesSearcher.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
math_ComputeGaussPointsAndWeights::math_ComputeGaussPointsAndWeights(const Standard_Integer Number)
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
|
71
src/math/math_ComputeGaussPointsAndWeights.hxx
Normal file
71
src/math/math_ComputeGaussPointsAndWeights.hxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Created on: 2005-12-19
|
||||
// Created by: Julia GERASIMOVA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_ComputeGaussPointsAndWeights_HeaderFile
|
||||
#define _math_ComputeGaussPointsAndWeights_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
|
||||
|
||||
class math_ComputeGaussPointsAndWeights
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT math_ComputeGaussPointsAndWeights(const Standard_Integer Number);
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||
|
||||
Standard_EXPORT math_Vector Points() const;
|
||||
|
||||
Standard_EXPORT math_Vector Weights() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Handle(TColStd_HArray1OfReal) myPoints;
|
||||
Handle(TColStd_HArray1OfReal) myWeights;
|
||||
Standard_Boolean myIsDone;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_ComputeGaussPointsAndWeights_HeaderFile
|
@@ -1,42 +0,0 @@
|
||||
-- Created on: 2005-12-21
|
||||
-- Created by: Julia GERASIMOVA
|
||||
-- Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class ComputeKronrodPointsAndWeights from math
|
||||
|
||||
uses
|
||||
|
||||
Vector from math,
|
||||
HArray1OfReal from TColStd
|
||||
|
||||
is
|
||||
Create(Number : Integer from Standard)
|
||||
returns ComputeKronrodPointsAndWeights;
|
||||
|
||||
IsDone(me)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Points(me)
|
||||
returns Vector from math;
|
||||
|
||||
Weights(me)
|
||||
returns Vector from math;
|
||||
|
||||
fields
|
||||
|
||||
myPoints : HArray1OfReal from TColStd;
|
||||
myWeights : HArray1OfReal from TColStd;
|
||||
myIsDone : Boolean from Standard;
|
||||
|
||||
end ComputeKronrodPointsAndWeights;
|
@@ -13,13 +13,13 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_ComputeKronrodPointsAndWeights.ixx>
|
||||
#include <math_EigenValuesSearcher.hxx>
|
||||
|
||||
#include <math_Array1OfValueAndWeight.hxx>
|
||||
#include <math_ComputeKronrodPointsAndWeights.hxx>
|
||||
#include <math_EigenValuesSearcher.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const Standard_Integer Number)
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
|
71
src/math/math_ComputeKronrodPointsAndWeights.hxx
Normal file
71
src/math/math_ComputeKronrodPointsAndWeights.hxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Created on: 2005-12-21
|
||||
// Created by: Julia GERASIMOVA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_ComputeKronrodPointsAndWeights_HeaderFile
|
||||
#define _math_ComputeKronrodPointsAndWeights_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
|
||||
|
||||
class math_ComputeKronrodPointsAndWeights
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT math_ComputeKronrodPointsAndWeights(const Standard_Integer Number);
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||
|
||||
Standard_EXPORT math_Vector Points() const;
|
||||
|
||||
Standard_EXPORT math_Vector Weights() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Handle(TColStd_HArray1OfReal) myPoints;
|
||||
Handle(TColStd_HArray1OfReal) myWeights;
|
||||
Standard_Boolean myIsDone;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_ComputeKronrodPointsAndWeights_HeaderFile
|
@@ -1,117 +0,0 @@
|
||||
-- Created on: 1991-08-22
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class Crout from math
|
||||
|
||||
---Purpose: This class implements the Crout algorithm used to solve a
|
||||
-- system A*X = B where A is a symmetric matrix. It can be used to
|
||||
-- invert a symmetric matrix.
|
||||
-- This algorithm is similar to Gauss but is faster than Gauss.
|
||||
-- Only the inferior triangle of A and the diagonal can be given.
|
||||
|
||||
|
||||
uses Matrix from math,
|
||||
Vector from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail,
|
||||
NotSquare from math,
|
||||
DimensionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(A: Matrix; MinPivot: Real = 1.0e-20)
|
||||
---Purpose: Given an input matrix A, this algorithm inverts A by the
|
||||
-- Crout algorithm. The user can give only the inferior
|
||||
-- triangle for the implementation.
|
||||
-- A can be decomposed like this:
|
||||
-- A = L * D * T(L) where L is triangular inferior and D is
|
||||
-- diagonal.
|
||||
-- If one element of A is less than MinPivot, A is
|
||||
-- considered as singular.
|
||||
-- Exception NotSquare is raised if A is not a square matrix.
|
||||
|
||||
returns Crout
|
||||
raises NotSquare;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns True if all has been correctly done.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Solve(me; B: Vector; X: out Vector)
|
||||
---Purpose: Given an input vector <B>, this routine returns the
|
||||
-- solution of the set of linear equations A . X = B.
|
||||
-- Exception NotDone is raised if the decomposition was not
|
||||
-- done successfully.
|
||||
-- Exception DimensionError is raised if the range of B is
|
||||
-- not equal to the rowrange of A.
|
||||
|
||||
raises NotDone,
|
||||
DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Inverse(me)
|
||||
---Purpose: returns the inverse matrix of A. Only the inferior
|
||||
-- triangle is returned.
|
||||
-- Exception NotDone is raised if NotDone.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Matrix
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Invert(me; Inv: out Matrix)
|
||||
---Purpose: returns in Inv the inverse matrix of A. Only the inferior
|
||||
-- triangle is returned.
|
||||
-- Exception NotDone is raised if NotDone.
|
||||
---C++: inline
|
||||
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Determinant(me)
|
||||
---Purpose: Returns the value of the determinant of the previously LU
|
||||
-- decomposed matrix A. Zero is returned if the matrix A is considered as singular.
|
||||
-- Exceptions
|
||||
-- StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
InvA: Matrix;
|
||||
Done: Boolean;
|
||||
Det: Real;
|
||||
|
||||
end Crout;
|
@@ -18,12 +18,15 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_Crout.ixx>
|
||||
#include <math_Crout.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_NotSquare.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_Crout::math_Crout(const math_Matrix& A, const Standard_Real MinPivot):
|
||||
InvA(1, A.RowNumber(), 1, A.ColNumber())
|
||||
|
116
src/math/math_Crout.hxx
Normal file
116
src/math/math_Crout.hxx
Normal file
@@ -0,0 +1,116 @@
|
||||
// Created on: 1991-08-22
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_Crout_HeaderFile
|
||||
#define _math_Crout_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <math_Matrix.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_NotSquare;
|
||||
class Standard_DimensionError;
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
//! This class implements the Crout algorithm used to solve a
|
||||
//! system A*X = B where A is a symmetric matrix. It can be used to
|
||||
//! invert a symmetric matrix.
|
||||
//! This algorithm is similar to Gauss but is faster than Gauss.
|
||||
//! Only the inferior triangle of A and the diagonal can be given.
|
||||
class math_Crout
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Given an input matrix A, this algorithm inverts A by the
|
||||
//! Crout algorithm. The user can give only the inferior
|
||||
//! triangle for the implementation.
|
||||
//! A can be decomposed like this:
|
||||
//! A = L * D * T(L) where L is triangular inferior and D is
|
||||
//! diagonal.
|
||||
//! If one element of A is less than MinPivot, A is
|
||||
//! considered as singular.
|
||||
//! Exception NotSquare is raised if A is not a square matrix.
|
||||
Standard_EXPORT math_Crout(const math_Matrix& A, const Standard_Real MinPivot = 1.0e-20);
|
||||
|
||||
//! Returns True if all has been correctly done.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Given an input vector <B>, this routine returns the
|
||||
//! solution of the set of linear equations A . X = B.
|
||||
//! Exception NotDone is raised if the decomposition was not
|
||||
//! done successfully.
|
||||
//! Exception DimensionError is raised if the range of B is
|
||||
//! not equal to the rowrange of A.
|
||||
Standard_EXPORT void Solve (const math_Vector& B, math_Vector& X) const;
|
||||
|
||||
//! returns the inverse matrix of A. Only the inferior
|
||||
//! triangle is returned.
|
||||
//! Exception NotDone is raised if NotDone.
|
||||
const math_Matrix& Inverse() const;
|
||||
|
||||
//! returns in Inv the inverse matrix of A. Only the inferior
|
||||
//! triangle is returned.
|
||||
//! Exception NotDone is raised if NotDone.
|
||||
void Invert (math_Matrix& Inv) const;
|
||||
|
||||
//! Returns the value of the determinant of the previously LU
|
||||
//! decomposed matrix A. Zero is returned if the matrix A is considered as singular.
|
||||
//! Exceptions
|
||||
//! StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
Standard_Real Determinant() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
math_Matrix InvA;
|
||||
Standard_Boolean Done;
|
||||
Standard_Real Det;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_Crout.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_Crout_HeaderFile
|
@@ -1,122 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class DirectPolynomialRoots from math
|
||||
---Purpose:
|
||||
-- This class implements the calculation of all the real roots of a real
|
||||
-- polynomial of degree <= 4 using a direct method. Once found,
|
||||
-- the roots are polished using the Newton method.
|
||||
|
||||
uses OStream from Standard
|
||||
|
||||
raises RangeError from Standard,
|
||||
InfiniteSolutions from StdFail
|
||||
|
||||
is
|
||||
Create(A, B, C, D, E: Real)
|
||||
---Purpose:
|
||||
-- computes all the real roots of the polynomial
|
||||
-- Ax4 + Bx3 + Cx2 + Dx + E using a direct method.
|
||||
returns DirectPolynomialRoots;
|
||||
|
||||
|
||||
|
||||
Create(A, B, C, D: Real)
|
||||
---Purpose:
|
||||
-- computes all the real roots of the polynomial
|
||||
-- Ax3 + Bx2 + Cx + D using a direct method.
|
||||
|
||||
returns DirectPolynomialRoots;
|
||||
|
||||
|
||||
|
||||
Create(A, B, C: Real)
|
||||
---Purpose:
|
||||
-- computes all the real roots of the polynomial
|
||||
-- Ax2 + Bx + C using a direct method.
|
||||
|
||||
returns DirectPolynomialRoots;
|
||||
|
||||
|
||||
Create(A, B: Real)
|
||||
---Purpose:
|
||||
-- computes the real root of the polynomial Ax + B.
|
||||
|
||||
returns DirectPolynomialRoots;
|
||||
|
||||
|
||||
Solve(me: in out; A, B, C, D, E: Real)
|
||||
is static protected;
|
||||
|
||||
Solve(me: in out; A, B, C, D: Real)
|
||||
is static protected;
|
||||
|
||||
Solve(me: in out; A, B, C: Real)
|
||||
is static protected;
|
||||
|
||||
Solve(me: in out; A, B: Real)
|
||||
is static protected;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
InfiniteRoots(me)
|
||||
---Purpose: Returns true if there is an infinity of roots, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
NbSolutions(me)
|
||||
---Purpose: returns the number of solutions.
|
||||
-- An exception is raised if there are an infinity of roots.
|
||||
---C++: inline
|
||||
returns Integer
|
||||
raises InfiniteSolutions
|
||||
is static;
|
||||
|
||||
|
||||
Value(me; Nieme: Integer)
|
||||
---Purpose: returns the value of the Nieme root.
|
||||
-- An exception is raised if there are an infinity of roots.
|
||||
-- Exception RangeError is raised if Nieme is < 1
|
||||
-- or Nieme > NbSolutions.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises InfiniteSolutions, RangeError
|
||||
is static;
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
InfiniteStatus: Boolean;
|
||||
NbSol: Integer;
|
||||
TheRoots: Real[4];
|
||||
|
||||
end DirectPolynomialRoots;
|
@@ -16,20 +16,17 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_DirectPolynomialRoots.ixx>
|
||||
|
||||
#include <math_DirectPolynomialRoots.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <StdFail_InfiniteSolutions.hxx>
|
||||
|
||||
|
||||
#include <StdFail_InfiniteSolutions.hxx>
|
||||
|
||||
// Reference pour solution equation 3ieme degre et 2ieme degre :
|
||||
// ALGORITHMES NUMERIQUES ANALYSE ET MISE EN OEUVRE, tome 2
|
||||
// (equations et systemes non lineaires)
|
||||
// J. VIGNES editions TECHNIP.
|
||||
|
||||
const Standard_Real ZERO = 1.0e-30;
|
||||
const Standard_Real EPSILON = RealEpsilon();
|
||||
const Standard_Real RADIX = 2;
|
||||
|
119
src/math/math_DirectPolynomialRoots.hxx
Normal file
119
src/math/math_DirectPolynomialRoots.hxx
Normal file
@@ -0,0 +1,119 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_DirectPolynomialRoots_HeaderFile
|
||||
#define _math_DirectPolynomialRoots_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_RangeError;
|
||||
class StdFail_InfiniteSolutions;
|
||||
|
||||
|
||||
|
||||
//! This class implements the calculation of all the real roots of a real
|
||||
//! polynomial of degree <= 4 using a direct method. Once found,
|
||||
//! the roots are polished using the Newton method.
|
||||
class math_DirectPolynomialRoots
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! computes all the real roots of the polynomial
|
||||
//! Ax4 + Bx3 + Cx2 + Dx + E using a direct method.
|
||||
Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D, const Standard_Real E);
|
||||
|
||||
|
||||
//! computes all the real roots of the polynomial
|
||||
//! Ax3 + Bx2 + Cx + D using a direct method.
|
||||
Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D);
|
||||
|
||||
|
||||
//! computes all the real roots of the polynomial
|
||||
//! Ax2 + Bx + C using a direct method.
|
||||
Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C);
|
||||
|
||||
|
||||
//! computes the real root of the polynomial Ax + B.
|
||||
Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns true if there is an infinity of roots, otherwise returns false.
|
||||
Standard_Boolean InfiniteRoots() const;
|
||||
|
||||
//! returns the number of solutions.
|
||||
//! An exception is raised if there are an infinity of roots.
|
||||
Standard_Integer NbSolutions() const;
|
||||
|
||||
//! returns the value of the Nieme root.
|
||||
//! An exception is raised if there are an infinity of roots.
|
||||
//! Exception RangeError is raised if Nieme is < 1
|
||||
//! or Nieme > NbSolutions.
|
||||
Standard_Real Value (const Standard_Integer Nieme) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D, const Standard_Real E);
|
||||
|
||||
Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D);
|
||||
|
||||
Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B, const Standard_Real C);
|
||||
|
||||
Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Boolean InfiniteStatus;
|
||||
Standard_Integer NbSol;
|
||||
Standard_Real TheRoots[4];
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_DirectPolynomialRoots.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_DirectPolynomialRoots_HeaderFile
|
@@ -1,71 +0,0 @@
|
||||
-- Created on: 1992-02-07
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1992-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class DoubleTab from math
|
||||
uses Address from Standard
|
||||
is
|
||||
|
||||
Create(LowerRow, UpperRow, LowerCol, UpperCol: Integer)
|
||||
returns DoubleTab;
|
||||
|
||||
Create(Tab : Address; LowerRow, UpperRow, LowerCol, UpperCol: Integer)
|
||||
returns DoubleTab;
|
||||
|
||||
Init(me : in out; InitValue: Real) is static;
|
||||
|
||||
Create(Other: DoubleTab)
|
||||
returns DoubleTab;
|
||||
|
||||
Allocate(me : in out) is private;
|
||||
|
||||
Copy(me; Other: in out DoubleTab)
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
SetLowerRow(me: in out; LowerRow: Integer)
|
||||
is static;
|
||||
|
||||
|
||||
SetLowerCol(me: in out; LowerCol: Integer)
|
||||
is static;
|
||||
|
||||
|
||||
Value(me; RowIndex, ColIndex: Integer)
|
||||
---C++: alias operator()
|
||||
---C++: return &
|
||||
---C++: inline
|
||||
returns Real
|
||||
is static;
|
||||
|
||||
|
||||
Free(me: in out)
|
||||
---C++: alias ~
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Addr : Address;
|
||||
Buf : Real[16];
|
||||
isAllocated : Boolean;
|
||||
LowR : Integer;
|
||||
UppR : Integer;
|
||||
LowC : Integer;
|
||||
UppC : Integer;
|
||||
|
||||
end DoubleTab;
|
@@ -13,11 +13,11 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// Lpa, le 7/02/92
|
||||
#include <math_DoubleTab.ixx>
|
||||
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <math_DoubleTab.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
// macro to get size of C array
|
||||
#define CARRAY_LENGTH(arr) (int)(sizeof(arr)/sizeof(arr[0]))
|
||||
|
97
src/math/math_DoubleTab.hxx
Normal file
97
src/math/math_DoubleTab.hxx
Normal file
@@ -0,0 +1,97 @@
|
||||
// Created on: 1992-02-07
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1992-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_DoubleTab_HeaderFile
|
||||
#define _math_DoubleTab_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Address.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
|
||||
|
||||
class math_DoubleTab
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT math_DoubleTab(const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol);
|
||||
|
||||
Standard_EXPORT math_DoubleTab(const Standard_Address Tab, const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol);
|
||||
|
||||
Standard_EXPORT void Init (const Standard_Real InitValue);
|
||||
|
||||
Standard_EXPORT math_DoubleTab(const math_DoubleTab& Other);
|
||||
|
||||
void Copy (math_DoubleTab& Other) const;
|
||||
|
||||
Standard_EXPORT void SetLowerRow (const Standard_Integer LowerRow);
|
||||
|
||||
Standard_EXPORT void SetLowerCol (const Standard_Integer LowerCol);
|
||||
|
||||
Standard_Real& Value (const Standard_Integer RowIndex, const Standard_Integer ColIndex) const;
|
||||
Standard_Real& operator() (const Standard_Integer RowIndex, const Standard_Integer ColIndex) const
|
||||
{
|
||||
return Value(RowIndex,ColIndex);
|
||||
}
|
||||
|
||||
Standard_EXPORT void Free();
|
||||
~math_DoubleTab()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Standard_EXPORT void Allocate();
|
||||
|
||||
|
||||
Standard_Address Addr;
|
||||
Standard_Real Buf[16];
|
||||
Standard_Boolean isAllocated;
|
||||
Standard_Integer LowR;
|
||||
Standard_Integer UppR;
|
||||
Standard_Integer LowC;
|
||||
Standard_Integer UppC;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_DoubleTab.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_DoubleTab_HeaderFile
|
@@ -1,66 +0,0 @@
|
||||
-- Created on: 2005-12-15
|
||||
-- Created by: Julia GERASIMOVA
|
||||
-- Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class EigenValuesSearcher from math
|
||||
---Purpose: This class finds eigen values and vectors of
|
||||
-- real symmetric tridiagonal matrix
|
||||
|
||||
uses
|
||||
|
||||
Array1OfReal from TColStd,
|
||||
HArray1OfReal from TColStd,
|
||||
HArray2OfReal from TColStd,
|
||||
Vector from math
|
||||
|
||||
raises
|
||||
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
Create(Diagonal : Array1OfReal from TColStd;
|
||||
Subdiagonal : Array1OfReal from TColStd)
|
||||
returns EigenValuesSearcher
|
||||
raises NotDone; -- if length(Subdiagonal) != length(Diagonal)-1
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns Standard_True if computation is performed
|
||||
-- successfully.
|
||||
returns Boolean from Standard;
|
||||
|
||||
Dimension(me)
|
||||
---Purpose: Returns the dimension of matrix
|
||||
returns Integer from Standard;
|
||||
|
||||
EigenValue(me; Index : Integer from Standard)
|
||||
---Purpose: Returns the Index_th eigen value of matrix
|
||||
-- Index must be in [1, Dimension()]
|
||||
returns Real from Standard;
|
||||
|
||||
EigenVector(me; Index : Integer from Standard)
|
||||
---Purpose: Returns the Index_th eigen vector of matrix
|
||||
-- Index must be in [1, Dimension()]
|
||||
returns Vector from math;
|
||||
|
||||
fields
|
||||
|
||||
myDiagonal : HArray1OfReal from TColStd;
|
||||
mySubdiagonal : HArray1OfReal from TColStd;
|
||||
|
||||
myIsDone : Boolean from Standard;
|
||||
myN : Integer from Standard;
|
||||
myEigenValues : HArray1OfReal from TColStd;
|
||||
myEigenVectors : HArray2OfReal from TColStd;
|
||||
|
||||
end EigenValuesSearcher;
|
@@ -13,13 +13,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_EigenValuesSearcher.ixx>
|
||||
|
||||
#include <math_EigenValuesSearcher.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
//==========================================================================
|
||||
//function : pythag
|
||||
// Computation of sqrt(x*x + y*y).
|
||||
//==========================================================================
|
||||
|
||||
static inline Standard_Real pythag(const Standard_Real x,
|
||||
const Standard_Real y)
|
||||
{
|
||||
|
88
src/math/math_EigenValuesSearcher.hxx
Normal file
88
src/math/math_EigenValuesSearcher.hxx
Normal file
@@ -0,0 +1,88 @@
|
||||
// Created on: 2005-12-15
|
||||
// Created by: Julia GERASIMOVA
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_EigenValuesSearcher_HeaderFile
|
||||
#define _math_EigenValuesSearcher_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
class StdFail_NotDone;
|
||||
|
||||
|
||||
//! This class finds eigen values and vectors of
|
||||
//! real symmetric tridiagonal matrix
|
||||
class math_EigenValuesSearcher
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT math_EigenValuesSearcher(const TColStd_Array1OfReal& Diagonal, const TColStd_Array1OfReal& Subdiagonal);
|
||||
|
||||
//! Returns Standard_True if computation is performed
|
||||
//! successfully.
|
||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns the dimension of matrix
|
||||
Standard_EXPORT Standard_Integer Dimension() const;
|
||||
|
||||
//! Returns the Index_th eigen value of matrix
|
||||
//! Index must be in [1, Dimension()]
|
||||
Standard_EXPORT Standard_Real EigenValue (const Standard_Integer Index) const;
|
||||
|
||||
//! Returns the Index_th eigen vector of matrix
|
||||
//! Index must be in [1, Dimension()]
|
||||
Standard_EXPORT math_Vector EigenVector (const Standard_Integer Index) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Handle(TColStd_HArray1OfReal) myDiagonal;
|
||||
Handle(TColStd_HArray1OfReal) mySubdiagonal;
|
||||
Standard_Boolean myIsDone;
|
||||
Standard_Integer myN;
|
||||
Handle(TColStd_HArray1OfReal) myEigenValues;
|
||||
Handle(TColStd_HArray2OfReal) myEigenVectors;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_EigenValuesSearcher_HeaderFile
|
@@ -1,161 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class FRPR from math
|
||||
---Purpose:
|
||||
-- this class implements the Fletcher-Reeves-Polak_Ribiere minimization
|
||||
-- algorithm of a function of multiple variables.
|
||||
-- Knowledge of the function's gradient is required.
|
||||
|
||||
uses Vector from math, Matrix from math,
|
||||
MultipleVarFunctionWithGradient from math,
|
||||
Status from math,
|
||||
OStream from Standard
|
||||
|
||||
raises DimensionError from Standard,
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(theFunction: in MultipleVarFunctionWithGradient;
|
||||
theTolerance: Real;
|
||||
theNbIterations: Integer = 200;
|
||||
theZEPS: Real = 1.0e-12)
|
||||
---Purpose:
|
||||
-- Initializes the computation of the minimum of F.
|
||||
-- Warning: constructor does not perform computations.
|
||||
returns FRPR;
|
||||
|
||||
Delete(me) is static;
|
||||
---Purpose: Destructor alias.
|
||||
---C++: alias " Standard_EXPORT virtual ~math_FRPR();"
|
||||
|
||||
|
||||
Perform(me: in out;
|
||||
theFunction: in out MultipleVarFunctionWithGradient;
|
||||
theStartingPoint: Vector)
|
||||
---Purpose:
|
||||
-- The solution F = Fi is found when
|
||||
-- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
|
||||
is static;
|
||||
|
||||
|
||||
IsSolutionReached(me: in out; theFunction: in out MultipleVarFunctionWithGradient)
|
||||
---Purpose:
|
||||
-- The solution F = Fi is found when:
|
||||
-- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
|
||||
-- The maximum number of iterations allowed is given by NbIterations.
|
||||
---C++:inline
|
||||
returns Boolean is virtual;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Location(me)
|
||||
---Purpose: returns the location vector of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Location(me; Loc: out Vector)
|
||||
---Purpose: outputs the location vector of the minimum in Loc.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
-- Exception DimensionError is raised if the range of Loc is not
|
||||
-- equal to the range of the StartingPoint.
|
||||
---C++: inline
|
||||
raises DimensionError,
|
||||
NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Minimum(me)
|
||||
---Purpose: returns the value of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Gradient(me)
|
||||
---Purpose: returns the gradient vector at the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Gradient(me; Grad: out Vector)
|
||||
---Purpose: outputs the gradient vector at the minimum in Grad.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
-- Exception DimensionError is raised if the range of Grad is not
|
||||
-- equal to the range of the StartingPoint.
|
||||
---C++: inline
|
||||
|
||||
raises DimensionError,
|
||||
NotDone
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: returns the number of iterations really done during the
|
||||
-- computation of the minimum.
|
||||
-- Exception NotDone is raised if the minimum was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
TheLocation: Vector is protected;
|
||||
TheGradient: Vector is protected;
|
||||
TheMinimum: Real is protected;
|
||||
PreviousMinimum: Real is protected;
|
||||
Iter: Integer;
|
||||
State: Integer;
|
||||
XTol: Real is protected;
|
||||
EPSZ: Real is protected;
|
||||
TheStatus: Status;
|
||||
Itermax: Integer;
|
||||
|
||||
end FRPR;
|
@@ -16,21 +16,22 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
//#endif
|
||||
|
||||
#include <math_FRPR.ixx>
|
||||
//#endif
|
||||
|
||||
#include <math_BracketMinimum.hxx>
|
||||
#include <math_BrentMinimum.hxx>
|
||||
#include <math_FRPR.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <math_MultipleVarFunction.hxx>
|
||||
#include <math_MultipleVarFunctionWithGradient.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
// l'utilisation de math_BrentMinumim pur trouver un minimum dans une direction
|
||||
// donnee n'est pas du tout optimale. voir peut etre interpolation cubique
|
||||
// classique et aussi essayer "recherche unidimensionnelle economique"
|
||||
// PROGRAMMATION MATHEMATIQUE (theorie et algorithmes) tome1 page 82.
|
||||
|
||||
class DirFunctionTer : public math_Function {
|
||||
|
||||
math_Vector *P0;
|
||||
|
138
src/math/math_FRPR.hxx
Normal file
138
src/math/math_FRPR.hxx
Normal file
@@ -0,0 +1,138 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FRPR_HeaderFile
|
||||
#define _math_FRPR_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Status.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_DimensionError;
|
||||
class StdFail_NotDone;
|
||||
class math_MultipleVarFunctionWithGradient;
|
||||
|
||||
|
||||
|
||||
//! this class implements the Fletcher-Reeves-Polak_Ribiere minimization
|
||||
//! algorithm of a function of multiple variables.
|
||||
//! Knowledge of the function's gradient is required.
|
||||
class math_FRPR
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! Initializes the computation of the minimum of F.
|
||||
//! Warning: constructor does not perform computations.
|
||||
Standard_EXPORT math_FRPR(const math_MultipleVarFunctionWithGradient& theFunction, const Standard_Real theTolerance, const Standard_Integer theNbIterations = 200, const Standard_Real theZEPS = 1.0e-12);
|
||||
|
||||
//! Destructor alias.
|
||||
Standard_EXPORT void Delete() const;
|
||||
Standard_EXPORT virtual ~math_FRPR();
|
||||
|
||||
|
||||
//! The solution F = Fi is found when
|
||||
//! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
|
||||
Standard_EXPORT void Perform (math_MultipleVarFunctionWithGradient& theFunction, const math_Vector& theStartingPoint);
|
||||
|
||||
|
||||
//! The solution F = Fi is found when:
|
||||
//! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
|
||||
//! The maximum number of iterations allowed is given by NbIterations.
|
||||
virtual Standard_Boolean IsSolutionReached (math_MultipleVarFunctionWithGradient& theFunction);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the location vector of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
const math_Vector& Location() const;
|
||||
|
||||
//! outputs the location vector of the minimum in Loc.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
//! Exception DimensionError is raised if the range of Loc is not
|
||||
//! equal to the range of the StartingPoint.
|
||||
void Location (math_Vector& Loc) const;
|
||||
|
||||
//! returns the value of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Real Minimum() const;
|
||||
|
||||
//! returns the gradient vector at the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
const math_Vector& Gradient() const;
|
||||
|
||||
//! outputs the gradient vector at the minimum in Grad.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
//! Exception DimensionError is raised if the range of Grad is not
|
||||
//! equal to the range of the StartingPoint.
|
||||
void Gradient (math_Vector& Grad) const;
|
||||
|
||||
//! returns the number of iterations really done during the
|
||||
//! computation of the minimum.
|
||||
//! Exception NotDone is raised if the minimum was not found.
|
||||
Standard_Integer NbIterations() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
math_Vector TheLocation;
|
||||
math_Vector TheGradient;
|
||||
Standard_Real TheMinimum;
|
||||
Standard_Real PreviousMinimum;
|
||||
Standard_Real XTol;
|
||||
Standard_Real EPSZ;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Integer Iter;
|
||||
Standard_Integer State;
|
||||
math_Status TheStatus;
|
||||
Standard_Integer Itermax;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_FRPR.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FRPR_HeaderFile
|
@@ -1,57 +0,0 @@
|
||||
-- Created on: 1991-05-06
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class Function from math
|
||||
|
||||
---Purpose: This abstract class describes the virtual functions
|
||||
-- associated with a Function of a single variable.
|
||||
|
||||
is
|
||||
|
||||
Value(me: in out; X: Real; F: out Real)
|
||||
---Purpose: Computes the value of the function <F> for a given value of
|
||||
-- variable <X>.
|
||||
-- returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean
|
||||
is deferred;
|
||||
|
||||
|
||||
GetStateNumber(me: in out)
|
||||
---Purpose: returns the state of the function corresponding to the
|
||||
-- latest call of any methods associated with the function.
|
||||
-- This function is called by each of the algorithms
|
||||
-- described later which defined the function Integer
|
||||
-- Algorithm::StateNumber(). The algorithm has the
|
||||
-- responsibility to call this function when it has found
|
||||
-- a solution (i.e. a root or a minimum) and has to maintain
|
||||
-- the association between the solution found and this
|
||||
-- StateNumber.
|
||||
-- Byu default, this method returns 0 (which means for the
|
||||
-- algorithm: no state has been saved). It is the
|
||||
-- responsibility of the programmer to decide if he needs
|
||||
-- to save the current state of the function and to return
|
||||
-- an Integer that allows retrieval of the state.
|
||||
|
||||
returns Integer
|
||||
is virtual;
|
||||
|
||||
|
||||
end Function;
|
||||
|
||||
|
||||
|
@@ -12,7 +12,8 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <math_Function.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Function.ixx>
|
||||
|
||||
Standard_Integer math_Function::GetStateNumber() { return 0; }
|
||||
|
83
src/math/math_Function.hxx
Normal file
83
src/math/math_Function.hxx
Normal file
@@ -0,0 +1,83 @@
|
||||
// Created on: 1991-05-06
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_Function_HeaderFile
|
||||
#define _math_Function_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
|
||||
//! This abstract class describes the virtual functions
|
||||
//! associated with a Function of a single variable.
|
||||
class math_Function
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Computes the value of the function <F> for a given value of
|
||||
//! variable <X>.
|
||||
//! returns True if the computation was done successfully,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Value (const Standard_Real X, Standard_Real& F) = 0;
|
||||
|
||||
//! returns the state of the function corresponding to the
|
||||
//! latest call of any methods associated with the function.
|
||||
//! This function is called by each of the algorithms
|
||||
//! described later which defined the function Integer
|
||||
//! Algorithm::StateNumber(). The algorithm has the
|
||||
//! responsibility to call this function when it has found
|
||||
//! a solution (i.e. a root or a minimum) and has to maintain
|
||||
//! the association between the solution found and this
|
||||
//! StateNumber.
|
||||
//! Byu default, this method returns 0 (which means for the
|
||||
//! algorithm: no state has been saved). It is the
|
||||
//! responsibility of the programmer to decide if he needs
|
||||
//! to save the current state of the function and to return
|
||||
//! an Integer that allows retrieval of the state.
|
||||
Standard_EXPORT virtual Standard_Integer GetStateNumber();
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_Function_HeaderFile
|
@@ -1,145 +0,0 @@
|
||||
-- Created on: 1991-07-17
|
||||
-- Created by: Isabelle GRIGNON
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class FunctionAllRoots from math
|
||||
|
||||
---Purpose: This algorithm uses a sample of the function to find
|
||||
-- all intervals on which the function is null, and afterwards
|
||||
-- uses the FunctionRoots algorithm to find the points
|
||||
-- where the function is null outside the "null intervals".
|
||||
-- Knowledge of the derivative is required.
|
||||
|
||||
|
||||
uses FunctionSample from math,
|
||||
FunctionRoots from math,
|
||||
FunctionWithDerivative from math,
|
||||
SequenceOfReal from TColStd,
|
||||
SequenceOfInteger from TColStd,
|
||||
OStream from Standard
|
||||
|
||||
raises OutOfRange from Standard,
|
||||
NotDone from StdFail,
|
||||
NumericError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out FunctionWithDerivative from math;
|
||||
S: FunctionSample from math;
|
||||
EpsX, EpsF, EpsNul: Real)
|
||||
|
||||
---Purpose: The algorithm uses the sample to find intervals on which
|
||||
-- the function is null. An interval is found if, for at least
|
||||
-- two consecutive points of the sample, Ui and Ui+1, we get
|
||||
-- |F(Ui)|<=EpsNul and |F(Ui+1)|<=EpsNul. The real bounds of
|
||||
-- an interval are computed with the FunctionRoots.
|
||||
-- algorithm.
|
||||
-- Between two intervals, the roots of the function F are
|
||||
-- calculated using the FunctionRoots algorithm.
|
||||
|
||||
returns FunctionAllRoots
|
||||
|
||||
raises NumericError from Standard;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
|
||||
---Purpose: Returns True if the computation has been done successfully.
|
||||
---C++: inline
|
||||
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
NbIntervals(me)
|
||||
---Purpose: Returns the number of intervals on which the function
|
||||
-- is Null.
|
||||
-- An exception is raised if IsDone returns False.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
GetInterval(me; Index: Integer; A,B: out Real)
|
||||
---Purpose: Returns the interval of parameter of range Index.
|
||||
-- An exception is raised if IsDone returns False;
|
||||
-- An exception is raised if Index<=0 or Index >Nbintervals.
|
||||
---C++: inline
|
||||
|
||||
raises NotDone from StdFail, OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
|
||||
GetIntervalState(me; Index: Integer; IFirst, ILast: out Integer)
|
||||
---Purpose: returns the State Number associated to the interval Index.
|
||||
-- An exception is raised if IsDone returns False;
|
||||
-- An exception is raised if Index<=0 or Index >Nbintervals.
|
||||
---C++: inline
|
||||
|
||||
raises NotDone from StdFail, OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
|
||||
NbPoints(me)
|
||||
---Purpose: returns the number of points where the function is Null.
|
||||
-- An exception is raised if IsDone returns False.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
GetPoint(me; Index: Integer)
|
||||
---Purpose: Returns the parameter of the point of range Index.
|
||||
-- An exception is raised if IsDone returns False;
|
||||
-- An exception is raised if Index<=0 or Index >NbPoints.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone from StdFail, OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
|
||||
GetPointState(me; Index: Integer)
|
||||
---Purpose: returns the State Number associated to the point Index.
|
||||
-- An exception is raised if IsDone returns False;
|
||||
-- An exception is raised if Index<=0 or Index >Nbintervals.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone from StdFail, OutOfRange from Standard
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
done: Boolean;
|
||||
pdeb: SequenceOfReal from TColStd;
|
||||
pfin: SequenceOfReal from TColStd;
|
||||
piso: SequenceOfReal from TColStd;
|
||||
ideb: SequenceOfInteger from TColStd;
|
||||
ifin: SequenceOfInteger from TColStd;
|
||||
iiso: SequenceOfInteger from TColStd;
|
||||
|
||||
end FunctionAllRoots;
|
@@ -16,15 +16,16 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_FunctionAllRoots.ixx>
|
||||
|
||||
#include <math_FunctionAllRoots.hxx>
|
||||
#include <math_FunctionRoots.hxx>
|
||||
#include <math_FunctionSample.hxx>
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
#include <Standard_NumericError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <math_FunctionRoots.hxx>
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
#include <math_FunctionSample.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_FunctionAllRoots::math_FunctionAllRoots (
|
||||
math_FunctionWithDerivative& F,
|
||||
|
126
src/math/math_FunctionAllRoots.hxx
Normal file
126
src/math/math_FunctionAllRoots.hxx
Normal file
@@ -0,0 +1,126 @@
|
||||
// Created on: 1991-07-17
|
||||
// Created by: Isabelle GRIGNON
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionAllRoots_HeaderFile
|
||||
#define _math_FunctionAllRoots_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_OutOfRange;
|
||||
class StdFail_NotDone;
|
||||
class Standard_NumericError;
|
||||
class math_FunctionWithDerivative;
|
||||
class math_FunctionSample;
|
||||
|
||||
|
||||
//! This algorithm uses a sample of the function to find
|
||||
//! all intervals on which the function is null, and afterwards
|
||||
//! uses the FunctionRoots algorithm to find the points
|
||||
//! where the function is null outside the "null intervals".
|
||||
//! Knowledge of the derivative is required.
|
||||
class math_FunctionAllRoots
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! The algorithm uses the sample to find intervals on which
|
||||
//! the function is null. An interval is found if, for at least
|
||||
//! two consecutive points of the sample, Ui and Ui+1, we get
|
||||
//! |F(Ui)|<=EpsNul and |F(Ui+1)|<=EpsNul. The real bounds of
|
||||
//! an interval are computed with the FunctionRoots.
|
||||
//! algorithm.
|
||||
//! Between two intervals, the roots of the function F are
|
||||
//! calculated using the FunctionRoots algorithm.
|
||||
Standard_EXPORT math_FunctionAllRoots(math_FunctionWithDerivative& F, const math_FunctionSample& S, const Standard_Real EpsX, const Standard_Real EpsF, const Standard_Real EpsNul);
|
||||
|
||||
//! Returns True if the computation has been done successfully.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns the number of intervals on which the function
|
||||
//! is Null.
|
||||
//! An exception is raised if IsDone returns False.
|
||||
Standard_Integer NbIntervals() const;
|
||||
|
||||
//! Returns the interval of parameter of range Index.
|
||||
//! An exception is raised if IsDone returns False;
|
||||
//! An exception is raised if Index<=0 or Index >Nbintervals.
|
||||
void GetInterval (const Standard_Integer Index, Standard_Real& A, Standard_Real& B) const;
|
||||
|
||||
//! returns the State Number associated to the interval Index.
|
||||
//! An exception is raised if IsDone returns False;
|
||||
//! An exception is raised if Index<=0 or Index >Nbintervals.
|
||||
void GetIntervalState (const Standard_Integer Index, Standard_Integer& IFirst, Standard_Integer& ILast) const;
|
||||
|
||||
//! returns the number of points where the function is Null.
|
||||
//! An exception is raised if IsDone returns False.
|
||||
Standard_Integer NbPoints() const;
|
||||
|
||||
//! Returns the parameter of the point of range Index.
|
||||
//! An exception is raised if IsDone returns False;
|
||||
//! An exception is raised if Index<=0 or Index >NbPoints.
|
||||
Standard_Real GetPoint (const Standard_Integer Index) const;
|
||||
|
||||
//! returns the State Number associated to the point Index.
|
||||
//! An exception is raised if IsDone returns False;
|
||||
//! An exception is raised if Index<=0 or Index >Nbintervals.
|
||||
Standard_Integer GetPointState (const Standard_Integer Index) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean done;
|
||||
TColStd_SequenceOfReal pdeb;
|
||||
TColStd_SequenceOfReal pfin;
|
||||
TColStd_SequenceOfReal piso;
|
||||
TColStd_SequenceOfInteger ideb;
|
||||
TColStd_SequenceOfInteger ifin;
|
||||
TColStd_SequenceOfInteger iiso;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_FunctionAllRoots.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionAllRoots_HeaderFile
|
@@ -1,125 +0,0 @@
|
||||
-- Created on: 1991-03-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class FunctionRoot from math
|
||||
---Purpose:
|
||||
-- This class implements the computation of a root of a function of
|
||||
-- a single variable which is near an initial guess using a minimization
|
||||
-- algorithm.Knowledge of the derivative is required. The
|
||||
-- algorithm used is the same as in
|
||||
|
||||
uses Vector from math, Matrix from math,
|
||||
FunctionWithDerivative from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out FunctionWithDerivative;
|
||||
Guess, Tolerance: Real;
|
||||
NbIterations: Integer = 100)
|
||||
---Purpose:
|
||||
-- The Newton-Raphson method is done to find the root of the function F
|
||||
-- from the initial guess Guess.The tolerance required on
|
||||
-- the root is given by Tolerance. Iterations are stopped if
|
||||
-- the expected solution does not stay in the range A..B.
|
||||
-- The solution is found when abs(Xi - Xi-1) <= Tolerance;
|
||||
-- The maximum number of iterations allowed is given by NbIterations.
|
||||
|
||||
returns FunctionRoot;
|
||||
|
||||
|
||||
Create(F: in out FunctionWithDerivative;
|
||||
Guess, Tolerance,A,B: Real;
|
||||
NbIterations: Integer = 100)
|
||||
---Purpose:
|
||||
-- The Newton-Raphson method is done to find the root of the function F
|
||||
-- from the initial guess Guess.
|
||||
-- The tolerance required on the root is given by Tolerance.
|
||||
-- Iterations are stopped if the expected solution does not stay in the
|
||||
-- range A..B
|
||||
-- The solution is found when abs(Xi - Xi-1) <= Tolerance;
|
||||
-- The maximum number of iterations allowed is given by NbIterations.
|
||||
|
||||
returns FunctionRoot;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Root(me)
|
||||
---Purpose: returns the value of the root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Derivative(me)
|
||||
---Purpose: returns the value of the derivative at the root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns the value of the function at the root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: returns the number of iterations really done on the
|
||||
-- computation of the Root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
TheRoot: Real ;
|
||||
TheError: Real ;
|
||||
TheDerivative: Real ;
|
||||
NbIter: Integer;
|
||||
|
||||
end FunctionRoot;
|
@@ -16,15 +16,15 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <math_FunctionRoot.ixx>
|
||||
#include <math_FunctionRoot.hxx>
|
||||
#include <math_FunctionSetRoot.hxx>
|
||||
|
||||
#include <math_FunctionSetWithDerivatives.hxx>
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
class math_MyFunctionSetWithDerivatives : public math_FunctionSetWithDerivatives {
|
||||
|
||||
|
117
src/math/math_FunctionRoot.hxx
Normal file
117
src/math/math_FunctionRoot.hxx
Normal file
@@ -0,0 +1,117 @@
|
||||
// Created on: 1991-03-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionRoot_HeaderFile
|
||||
#define _math_FunctionRoot_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_FunctionWithDerivative;
|
||||
|
||||
|
||||
|
||||
//! This class implements the computation of a root of a function of
|
||||
//! a single variable which is near an initial guess using a minimization
|
||||
//! algorithm.Knowledge of the derivative is required. The
|
||||
//! algorithm used is the same as in
|
||||
class math_FunctionRoot
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! The Newton-Raphson method is done to find the root of the function F
|
||||
//! from the initial guess Guess.The tolerance required on
|
||||
//! the root is given by Tolerance. Iterations are stopped if
|
||||
//! the expected solution does not stay in the range A..B.
|
||||
//! The solution is found when abs(Xi - Xi-1) <= Tolerance;
|
||||
//! The maximum number of iterations allowed is given by NbIterations.
|
||||
Standard_EXPORT math_FunctionRoot(math_FunctionWithDerivative& F, const Standard_Real Guess, const Standard_Real Tolerance, const Standard_Integer NbIterations = 100);
|
||||
|
||||
|
||||
//! The Newton-Raphson method is done to find the root of the function F
|
||||
//! from the initial guess Guess.
|
||||
//! The tolerance required on the root is given by Tolerance.
|
||||
//! Iterations are stopped if the expected solution does not stay in the
|
||||
//! range A..B
|
||||
//! The solution is found when abs(Xi - Xi-1) <= Tolerance;
|
||||
//! The maximum number of iterations allowed is given by NbIterations.
|
||||
Standard_EXPORT math_FunctionRoot(math_FunctionWithDerivative& F, const Standard_Real Guess, const Standard_Real Tolerance, const Standard_Real A, const Standard_Real B, const Standard_Integer NbIterations = 100);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the value of the root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
Standard_Real Root() const;
|
||||
|
||||
//! returns the value of the derivative at the root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
Standard_Real Derivative() const;
|
||||
|
||||
//! returns the value of the function at the root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
Standard_Real Value() const;
|
||||
|
||||
//! returns the number of iterations really done on the
|
||||
//! computation of the Root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
Standard_Integer NbIterations() const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Real TheRoot;
|
||||
Standard_Real TheError;
|
||||
Standard_Real TheDerivative;
|
||||
Standard_Integer NbIter;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_FunctionRoot.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionRoot_HeaderFile
|
@@ -1,110 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class FunctionRoots from math
|
||||
---Purpose:
|
||||
-- This class implements an algorithm which finds all the real roots of
|
||||
-- a function with derivative within a given range.
|
||||
-- Knowledge of the derivative is required.
|
||||
|
||||
uses FunctionWithDerivative from math,
|
||||
SequenceOfReal from TColStd,
|
||||
SequenceOfInteger from TColStd,
|
||||
OStream from Standard
|
||||
|
||||
raises RangeError from Standard,
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out FunctionWithDerivative; A, B: Real;
|
||||
NbSample: Integer; EpsX, EpsF, EpsNull, K : Real= 0.0)
|
||||
|
||||
---Purpose: Calculates all the real roots of a function F-K within the range
|
||||
-- A..B. whithout conditions on A and B
|
||||
-- A solution X is found when
|
||||
-- abs(Xi - Xi-1) <= Epsx and abs(F(Xi)-K) <= EpsF.
|
||||
-- The function is considered as null between A and B if
|
||||
-- abs(F-K) <= EpsNull within this range.
|
||||
|
||||
returns FunctionRoots;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
IsAllNull(me)
|
||||
---Purpose:
|
||||
-- returns true if the function is considered as null between A and B.
|
||||
-- Exceptions
|
||||
-- StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
NbSolutions(me)
|
||||
---Purpose: Returns the number of solutions found.
|
||||
-- Exceptions
|
||||
-- StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
---C++: inline
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Value(me; Nieme: in Integer)
|
||||
---Purpose: Returns the Nth value of the root of function F.
|
||||
-- Exceptions
|
||||
-- StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone, RangeError
|
||||
is static;
|
||||
|
||||
|
||||
StateNumber(me; Nieme: in Integer)
|
||||
---Purpose:
|
||||
-- returns the StateNumber of the Nieme root.
|
||||
-- Exception RangeError is raised if Nieme is < 1
|
||||
-- or Nieme > NbSolutions.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
AllNull: Boolean;
|
||||
Sol: SequenceOfReal from TColStd;
|
||||
NbStateSol: SequenceOfInteger from TColStd;
|
||||
|
||||
end FunctionRoots;
|
@@ -16,18 +16,19 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <math_DirectPolynomialRoots.hxx>
|
||||
#include <math_FunctionRoots.ixx>
|
||||
#include <math_FunctionRoots.hxx>
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
//#ifdef WNT
|
||||
#include <stdio.h>
|
||||
//#endif
|
||||
|
||||
#include <stdio.h>
|
||||
//#ifdef WNT
|
||||
//#endif
|
||||
#define ITMAX 100
|
||||
#define EPS 1e-14
|
||||
#define EPSEPS 2e-14
|
||||
|
111
src/math/math_FunctionRoots.hxx
Normal file
111
src/math/math_FunctionRoots.hxx
Normal file
@@ -0,0 +1,111 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionRoots_HeaderFile
|
||||
#define _math_FunctionRoots_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_RangeError;
|
||||
class StdFail_NotDone;
|
||||
class math_FunctionWithDerivative;
|
||||
|
||||
|
||||
|
||||
//! This class implements an algorithm which finds all the real roots of
|
||||
//! a function with derivative within a given range.
|
||||
//! Knowledge of the derivative is required.
|
||||
class math_FunctionRoots
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Calculates all the real roots of a function F-K within the range
|
||||
//! A..B. whithout conditions on A and B
|
||||
//! A solution X is found when
|
||||
//! abs(Xi - Xi-1) <= Epsx and abs(F(Xi)-K) <= EpsF.
|
||||
//! The function is considered as null between A and B if
|
||||
//! abs(F-K) <= EpsNull within this range.
|
||||
Standard_EXPORT math_FunctionRoots(math_FunctionWithDerivative& F, const Standard_Real A, const Standard_Real B, const Standard_Integer NbSample, const Standard_Real EpsX = 0.0, const Standard_Real EpsF = 0.0, const Standard_Real EpsNull = 0.0, const Standard_Real K = 0.0);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
|
||||
//! returns true if the function is considered as null between A and B.
|
||||
//! Exceptions
|
||||
//! StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
Standard_Boolean IsAllNull() const;
|
||||
|
||||
//! Returns the number of solutions found.
|
||||
//! Exceptions
|
||||
//! StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
Standard_Integer NbSolutions() const;
|
||||
|
||||
//! Returns the Nth value of the root of function F.
|
||||
//! Exceptions
|
||||
//! StdFail_NotDone if the algorithm fails (and IsDone returns false).
|
||||
Standard_Real Value (const Standard_Integer Nieme) const;
|
||||
|
||||
|
||||
//! returns the StateNumber of the Nieme root.
|
||||
//! Exception RangeError is raised if Nieme is < 1
|
||||
//! or Nieme > NbSolutions.
|
||||
Standard_Integer StateNumber (const Standard_Integer Nieme) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Boolean AllNull;
|
||||
TColStd_SequenceOfReal Sol;
|
||||
TColStd_SequenceOfInteger NbStateSol;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_FunctionRoots.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionRoots_HeaderFile
|
@@ -1,64 +0,0 @@
|
||||
-- Created on: 1991-07-17
|
||||
-- Created by: Isabelle GRIGNON
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class FunctionSample from math
|
||||
|
||||
---Purpose: This class gives a default sample (constant difference
|
||||
-- of parameter) for a function defined between
|
||||
-- two bound A,B.
|
||||
|
||||
raises OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(A,B: Real; N: Integer)
|
||||
|
||||
returns FunctionSample from math;
|
||||
|
||||
|
||||
Bounds(me; A,B: out Real) is virtual;
|
||||
|
||||
---Purpose: Returns the bounds of parameters.
|
||||
|
||||
|
||||
|
||||
NbPoints(me)
|
||||
|
||||
---Purpose: Returns the number of sample points.
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
GetParameter(me; Index: Integer)
|
||||
|
||||
---Purpose: Returns the value of parameter of the point of
|
||||
-- range Index : A + ((Index-1)/(NbPoints-1))*B.
|
||||
-- An exception is raised if Index<=0 or Index>NbPoints.
|
||||
|
||||
returns Real
|
||||
raises OutOfRange
|
||||
is virtual;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
a: Real;
|
||||
b: Real;
|
||||
n: Integer;
|
||||
|
||||
end FunctionSample;
|
@@ -16,14 +16,12 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_FunctionSample.ixx>
|
||||
|
||||
|
||||
#include <math_FunctionSample.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
|
||||
math_FunctionSample::math_FunctionSample (const Standard_Real A,
|
||||
const Standard_Real B,
|
||||
const Standard_Integer N):
|
||||
|
78
src/math/math_FunctionSample.hxx
Normal file
78
src/math/math_FunctionSample.hxx
Normal file
@@ -0,0 +1,78 @@
|
||||
// Created on: 1991-07-17
|
||||
// Created by: Isabelle GRIGNON
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionSample_HeaderFile
|
||||
#define _math_FunctionSample_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
class Standard_OutOfRange;
|
||||
|
||||
|
||||
//! This class gives a default sample (constant difference
|
||||
//! of parameter) for a function defined between
|
||||
//! two bound A,B.
|
||||
class math_FunctionSample
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT math_FunctionSample(const Standard_Real A, const Standard_Real B, const Standard_Integer N);
|
||||
|
||||
//! Returns the bounds of parameters.
|
||||
Standard_EXPORT virtual void Bounds (Standard_Real& A, Standard_Real& B) const;
|
||||
|
||||
//! Returns the number of sample points.
|
||||
Standard_EXPORT Standard_Integer NbPoints() const;
|
||||
|
||||
//! Returns the value of parameter of the point of
|
||||
//! range Index : A + ((Index-1)/(NbPoints-1))*B.
|
||||
//! An exception is raised if Index<=0 or Index>NbPoints.
|
||||
Standard_EXPORT virtual Standard_Real GetParameter (const Standard_Integer Index) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Real a;
|
||||
Standard_Real b;
|
||||
Standard_Integer n;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionSample_HeaderFile
|
@@ -1,70 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class FunctionSet from math
|
||||
---Purpose:
|
||||
-- This abstract class describes the virtual functions associated to
|
||||
-- a set on N Functions of M independant variables.
|
||||
|
||||
uses Vector from math
|
||||
|
||||
is
|
||||
NbVariables(me)
|
||||
---Purpose: Returns the number of variables of the function.
|
||||
|
||||
returns Integer
|
||||
is deferred;
|
||||
|
||||
|
||||
NbEquations(me)
|
||||
---Purpose: Returns the number of equations of the function.
|
||||
|
||||
returns Integer
|
||||
is deferred;
|
||||
|
||||
|
||||
Value(me: in out; X: Vector; F: out Vector)
|
||||
---Purpose: Computes the values <F> of the functions for the
|
||||
-- variable <X>.
|
||||
-- returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
|
||||
GetStateNumber(me: in out)
|
||||
---Purpose: Returns the state of the function corresponding to the
|
||||
-- latestcall of any methods associated with the function.
|
||||
-- This function is called by each of the algorithms
|
||||
-- described later which define the function Integer
|
||||
-- Algorithm::StateNumber(). The algorithm has the
|
||||
-- responsibility to call this function when it has found
|
||||
-- a solution (i.e. a root or a minimum) and has to maintain
|
||||
-- the association between the solution found and this
|
||||
-- StateNumber.
|
||||
-- Byu default, this method returns 0 (which means for the
|
||||
-- algorithm: no state has been saved). It is the
|
||||
-- responsibility of the programmer to decide if he needs
|
||||
-- to save the current state of the function and to return
|
||||
-- an Integer that allows retrieval of the state.
|
||||
|
||||
returns Integer is virtual;
|
||||
|
||||
---C++: alias " Standard_EXPORT virtual ~math_FunctionSet();"
|
||||
|
||||
end FunctionSet;
|
||||
|
||||
|
@@ -12,8 +12,9 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <math_FunctionSet.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_FunctionSet.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ~math_FunctionSet
|
||||
@@ -30,4 +31,4 @@ math_FunctionSet::~math_FunctionSet()
|
||||
Standard_Integer math_FunctionSet::GetStateNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
91
src/math/math_FunctionSet.hxx
Normal file
91
src/math/math_FunctionSet.hxx
Normal file
@@ -0,0 +1,91 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionSet_HeaderFile
|
||||
#define _math_FunctionSet_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
|
||||
|
||||
//! This abstract class describes the virtual functions associated to
|
||||
//! a set on N Functions of M independant variables.
|
||||
class math_FunctionSet
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Returns the number of variables of the function.
|
||||
Standard_EXPORT virtual Standard_Integer NbVariables() const = 0;
|
||||
|
||||
//! Returns the number of equations of the function.
|
||||
Standard_EXPORT virtual Standard_Integer NbEquations() const = 0;
|
||||
|
||||
//! Computes the values <F> of the functions for the
|
||||
//! variable <X>.
|
||||
//! returns True if the computation was done successfully,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Value (const math_Vector& X, math_Vector& F) = 0;
|
||||
|
||||
//! Returns the state of the function corresponding to the
|
||||
//! latestcall of any methods associated with the function.
|
||||
//! This function is called by each of the algorithms
|
||||
//! described later which define the function Integer
|
||||
//! Algorithm::StateNumber(). The algorithm has the
|
||||
//! responsibility to call this function when it has found
|
||||
//! a solution (i.e. a root or a minimum) and has to maintain
|
||||
//! the association between the solution found and this
|
||||
//! StateNumber.
|
||||
//! Byu default, this method returns 0 (which means for the
|
||||
//! algorithm: no state has been saved). It is the
|
||||
//! responsibility of the programmer to decide if he needs
|
||||
//! to save the current state of the function and to return
|
||||
//! an Integer that allows retrieval of the state.
|
||||
Standard_EXPORT virtual Standard_Integer GetStateNumber();
|
||||
Standard_EXPORT virtual ~math_FunctionSet();
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionSet_HeaderFile
|
@@ -1,245 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class FunctionSetRoot from math
|
||||
---Purpose: The math_FunctionSetRoot class calculates the root
|
||||
-- of a set of N functions of M variables (N<M, N=M or N>M). Knowing
|
||||
-- an initial guess of the solution and using a minimization algorithm, a search
|
||||
-- is made in the Newton direction and then in the Gradient direction if there
|
||||
-- is no success in the Newton direction. This algorithm can also be
|
||||
-- used for functions minimization. Knowledge of all the partial
|
||||
-- derivatives (the Jacobian) is required.
|
||||
|
||||
|
||||
uses Vector from math,
|
||||
Matrix from math,
|
||||
IntegerVector from math,
|
||||
FunctionSetWithDerivatives from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail,
|
||||
DimensionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out FunctionSetWithDerivatives;
|
||||
Tolerance : Vector;
|
||||
NbIterations: Integer = 100)
|
||||
---Purpose: is used in a sub-class to initialize correctly all the fields
|
||||
-- of this class.
|
||||
-- The range (1, F.NbVariables()) must be especially
|
||||
-- respected for all vectors and matrix declarations.
|
||||
|
||||
returns FunctionSetRoot from math;
|
||||
|
||||
|
||||
|
||||
Create(F: in out FunctionSetWithDerivatives;
|
||||
NbIterations: Integer = 100)
|
||||
---Purpose: is used in a sub-class to initialize correctly all the fields
|
||||
-- of this class.
|
||||
-- The range (1, F.NbVariables()) must be especially
|
||||
-- respected for all vectors and matrix declarations.
|
||||
-- The method SetTolerance must be called after this
|
||||
-- constructor.
|
||||
|
||||
returns FunctionSetRoot from math;
|
||||
|
||||
|
||||
Delete(me) is static;
|
||||
---Purpose: Destructor alias.
|
||||
---C++: alias " Standard_EXPORT virtual ~math_FunctionSetRoot();"
|
||||
|
||||
|
||||
SetTolerance(me: in out; Tolerance: Vector)
|
||||
---Purpose: Initializes the tolerance values.
|
||||
is static;
|
||||
|
||||
IsSolutionReached(me: in out; F: in out FunctionSetWithDerivatives)
|
||||
---Purpose: This routine is called at the end of each iteration
|
||||
-- to check if the solution was found. It can be redefined
|
||||
-- in a sub-class to implement a specific test to stop the iterations.
|
||||
-- In this case, the solution is found when: abs(Xi - Xi-1) <= Tolerance
|
||||
-- for all unknowns.
|
||||
---C++: inline
|
||||
returns Boolean is virtual;
|
||||
|
||||
|
||||
Perform(me: in out;
|
||||
theFunction: in out FunctionSetWithDerivatives;
|
||||
theStartingPoint: Vector;
|
||||
theStopOnDivergent: Boolean from Standard = Standard_False)
|
||||
---Purpose:
|
||||
-- Improves the root of function from the initial guess point.
|
||||
-- The infinum and supremum may be given to constrain the solution.
|
||||
-- In this case, the solution is found when: abs(Xi - Xi-1)(j) <= Tolerance(j)
|
||||
-- for all unknowns.
|
||||
is static;
|
||||
|
||||
|
||||
Perform(me: in out;
|
||||
theFunction: in out FunctionSetWithDerivatives;
|
||||
theStartingPoint: Vector;
|
||||
theInfBound, theSupBound: Vector;
|
||||
theStopOnDivergent: Boolean from Standard = Standard_False)
|
||||
---Purpose:
|
||||
-- Improves the root of function from the initial guess point.
|
||||
-- The infinum and supremum may be given to constrain the solution.
|
||||
-- In this case, the solution is found when: abs(Xi - Xi-1) <= Tolerance
|
||||
-- for all unknowns.
|
||||
is static;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose:
|
||||
-- Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: Returns the number of iterations really done
|
||||
-- during the computation of the root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
StateNumber(me)
|
||||
---Purpose: returns the stateNumber (as returned by
|
||||
-- F.GetStateNumber()) associated to the root found.
|
||||
---C++: inline
|
||||
returns Integer
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Root(me)
|
||||
---Purpose: Returns the value of the root of function F.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Vector
|
||||
raises NotDone,
|
||||
DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Root(me; Root: out Vector)
|
||||
---Purpose: Outputs the root vector in Root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
-- Exception DimensionError is raised if the range of Root
|
||||
-- is not equal to the range of the StartingPoint.
|
||||
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
Derivative(me)
|
||||
---Purpose: Returns the matrix value of the derivative at the root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
returns Matrix
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Derivative(me; Der: out Matrix)
|
||||
---Purpose: outputs the matrix value of the derivative
|
||||
-- at the root in Der.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
-- Exception DimensionError is raised if the column range
|
||||
-- of <Der> is not equal to the range of the startingPoint.
|
||||
---C++: inline
|
||||
|
||||
raises NotDone,
|
||||
DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
FunctionSetErrors(me)
|
||||
---Purpose: returns the vector value of the error done
|
||||
-- on the functions at the root.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
FunctionSetErrors(me; Err: out Vector)
|
||||
---Purpose: outputs the vector value of the error done
|
||||
-- on the functions at the root in Err.
|
||||
-- Exception NotDone is raised if the root was not found.
|
||||
-- Exception DimensionError is raised if the range of Err
|
||||
-- is not equal to the range of the StartingPoint.
|
||||
|
||||
raises NotDone,
|
||||
DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
IsDivergent(me)
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done : Boolean;
|
||||
Delta : Vector is protected;
|
||||
Sol : Vector is protected;
|
||||
DF : Matrix is protected;
|
||||
Kount : Integer;
|
||||
State : Integer;
|
||||
Tol : Vector is protected;
|
||||
Itermax : Integer;
|
||||
|
||||
-- working tables
|
||||
|
||||
InfBound : Vector;
|
||||
SupBound : Vector;
|
||||
|
||||
SolSave : Vector;
|
||||
GH : Vector;
|
||||
DH : Vector;
|
||||
DHSave : Vector;
|
||||
FF : Vector;
|
||||
PreviousSolution : Vector;
|
||||
Save : Vector;
|
||||
Constraints : IntegerVector;
|
||||
Temp1 : Vector;
|
||||
Temp2 : Vector;
|
||||
Temp3 : Vector;
|
||||
Temp4 : Vector;
|
||||
myIsDivergent : Boolean from Standard;
|
||||
|
||||
end FunctionSetRoot;
|
@@ -21,22 +21,22 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
//#endif
|
||||
|
||||
//#endif
|
||||
//math_FunctionSetRoot.cxx
|
||||
|
||||
|
||||
#include <math_FunctionSetRoot.ixx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <math_BrentMinimum.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <math_FunctionSetRoot.hxx>
|
||||
#include <math_FunctionSetWithDerivatives.hxx>
|
||||
#include <math_Gauss.hxx>
|
||||
#include <math_SVD.hxx>
|
||||
#include <math_GaussLeastSquare.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <math_BrentMinimum.hxx>
|
||||
#include <math_FunctionSetWithDerivatives.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_SVD.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
//===========================================================================
|
||||
// - A partir d une solution de depart, recherche d une direction.( Newton la
|
||||
@@ -58,7 +58,6 @@
|
||||
// Sinon
|
||||
// On change de direction
|
||||
//============================================================================
|
||||
|
||||
#define FSR_DEBUG(arg)
|
||||
// Uncomment the following code to have debug output to cout
|
||||
//==========================================================
|
||||
|
192
src/math/math_FunctionSetRoot.hxx
Normal file
192
src/math/math_FunctionSetRoot.hxx
Normal file
@@ -0,0 +1,192 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionSetRoot_HeaderFile
|
||||
#define _math_FunctionSetRoot_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class Standard_DimensionError;
|
||||
class math_FunctionSetWithDerivatives;
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
//! The math_FunctionSetRoot class calculates the root
|
||||
//! of a set of N functions of M variables (N<M, N=M or N>M). Knowing
|
||||
//! an initial guess of the solution and using a minimization algorithm, a search
|
||||
//! is made in the Newton direction and then in the Gradient direction if there
|
||||
//! is no success in the Newton direction. This algorithm can also be
|
||||
//! used for functions minimization. Knowledge of all the partial
|
||||
//! derivatives (the Jacobian) is required.
|
||||
class math_FunctionSetRoot
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! is used in a sub-class to initialize correctly all the fields
|
||||
//! of this class.
|
||||
//! The range (1, F.NbVariables()) must be especially
|
||||
//! respected for all vectors and matrix declarations.
|
||||
Standard_EXPORT math_FunctionSetRoot(math_FunctionSetWithDerivatives& F, const math_Vector& Tolerance, const Standard_Integer NbIterations = 100);
|
||||
|
||||
//! is used in a sub-class to initialize correctly all the fields
|
||||
//! of this class.
|
||||
//! The range (1, F.NbVariables()) must be especially
|
||||
//! respected for all vectors and matrix declarations.
|
||||
//! The method SetTolerance must be called after this
|
||||
//! constructor.
|
||||
Standard_EXPORT math_FunctionSetRoot(math_FunctionSetWithDerivatives& F, const Standard_Integer NbIterations = 100);
|
||||
|
||||
//! Destructor alias.
|
||||
Standard_EXPORT void Delete() const;
|
||||
Standard_EXPORT virtual ~math_FunctionSetRoot();
|
||||
|
||||
//! Initializes the tolerance values.
|
||||
Standard_EXPORT void SetTolerance (const math_Vector& Tolerance);
|
||||
|
||||
//! This routine is called at the end of each iteration
|
||||
//! to check if the solution was found. It can be redefined
|
||||
//! in a sub-class to implement a specific test to stop the iterations.
|
||||
//! In this case, the solution is found when: abs(Xi - Xi-1) <= Tolerance
|
||||
//! for all unknowns.
|
||||
virtual Standard_Boolean IsSolutionReached (math_FunctionSetWithDerivatives& F);
|
||||
|
||||
|
||||
//! Improves the root of function from the initial guess point.
|
||||
//! The infinum and supremum may be given to constrain the solution.
|
||||
//! In this case, the solution is found when: abs(Xi - Xi-1)(j) <= Tolerance(j)
|
||||
//! for all unknowns.
|
||||
Standard_EXPORT void Perform (math_FunctionSetWithDerivatives& theFunction, const math_Vector& theStartingPoint, const Standard_Boolean theStopOnDivergent = Standard_False);
|
||||
|
||||
|
||||
//! Improves the root of function from the initial guess point.
|
||||
//! The infinum and supremum may be given to constrain the solution.
|
||||
//! In this case, the solution is found when: abs(Xi - Xi-1) <= Tolerance
|
||||
//! for all unknowns.
|
||||
Standard_EXPORT void Perform (math_FunctionSetWithDerivatives& theFunction, const math_Vector& theStartingPoint, const math_Vector& theInfBound, const math_Vector& theSupBound, const Standard_Boolean theStopOnDivergent = Standard_False);
|
||||
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns the number of iterations really done
|
||||
//! during the computation of the root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
Standard_Integer NbIterations() const;
|
||||
|
||||
//! returns the stateNumber (as returned by
|
||||
//! F.GetStateNumber()) associated to the root found.
|
||||
Standard_Integer StateNumber() const;
|
||||
|
||||
//! Returns the value of the root of function F.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
const math_Vector& Root() const;
|
||||
|
||||
//! Outputs the root vector in Root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
//! Exception DimensionError is raised if the range of Root
|
||||
//! is not equal to the range of the StartingPoint.
|
||||
Standard_EXPORT void Root (math_Vector& Root) const;
|
||||
|
||||
//! Returns the matrix value of the derivative at the root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
const math_Matrix& Derivative() const;
|
||||
|
||||
//! outputs the matrix value of the derivative
|
||||
//! at the root in Der.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
//! Exception DimensionError is raised if the column range
|
||||
//! of <Der> is not equal to the range of the startingPoint.
|
||||
void Derivative (math_Matrix& Der) const;
|
||||
|
||||
//! returns the vector value of the error done
|
||||
//! on the functions at the root.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
const math_Vector& FunctionSetErrors() const;
|
||||
|
||||
//! outputs the vector value of the error done
|
||||
//! on the functions at the root in Err.
|
||||
//! Exception NotDone is raised if the root was not found.
|
||||
//! Exception DimensionError is raised if the range of Err
|
||||
//! is not equal to the range of the StartingPoint.
|
||||
Standard_EXPORT void FunctionSetErrors (math_Vector& Err) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsDivergent() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
math_Vector Delta;
|
||||
math_Vector Sol;
|
||||
math_Matrix DF;
|
||||
math_Vector Tol;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
Standard_Integer Kount;
|
||||
Standard_Integer State;
|
||||
Standard_Integer Itermax;
|
||||
math_Vector InfBound;
|
||||
math_Vector SupBound;
|
||||
math_Vector SolSave;
|
||||
math_Vector GH;
|
||||
math_Vector DH;
|
||||
math_Vector DHSave;
|
||||
math_Vector FF;
|
||||
math_Vector PreviousSolution;
|
||||
math_Vector Save;
|
||||
math_IntegerVector Constraints;
|
||||
math_Vector Temp1;
|
||||
math_Vector Temp2;
|
||||
math_Vector Temp3;
|
||||
math_Vector Temp4;
|
||||
Standard_Boolean myIsDivergent;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_FunctionSetRoot.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionSetRoot_HeaderFile
|
@@ -1,72 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class FunctionSetWithDerivatives from math
|
||||
|
||||
inherits FunctionSet
|
||||
|
||||
---Purpose: This abstract class describes the virtual functions associated
|
||||
-- with a set of N Functions each of M independant variables.
|
||||
|
||||
uses Vector from math, Matrix from math
|
||||
|
||||
|
||||
is
|
||||
|
||||
NbVariables(me)
|
||||
---Purpose: Returns the number of variables of the function.
|
||||
|
||||
returns Integer
|
||||
is deferred;
|
||||
|
||||
|
||||
NbEquations(me)
|
||||
---Purpose: Returns the number of equations of the function.
|
||||
|
||||
returns Integer
|
||||
is deferred;
|
||||
|
||||
|
||||
Value(me: in out; X: Vector; F: out Vector)
|
||||
---Purpose: Computes the values <F> of the Functions for the
|
||||
-- variable <X>.
|
||||
-- Returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean
|
||||
is deferred;
|
||||
|
||||
|
||||
Derivatives(me: in out; X: Vector; D: out Matrix)
|
||||
---Purpose: Returns the values <D> of the derivatives for the
|
||||
-- variable <X>.
|
||||
-- Returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean
|
||||
is deferred;
|
||||
|
||||
|
||||
Values(me: in out; X: Vector; F: out Vector; D: out Matrix)
|
||||
---Purpose: returns the values <F> of the functions and the derivatives
|
||||
-- <D> for the variable <X>.
|
||||
-- Returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean
|
||||
is deferred;
|
||||
|
||||
end FunctionSetWithDerivatives;
|
@@ -12,4 +12,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_FunctionSetWithDerivatives.ixx>
|
||||
|
||||
#include <math_FunctionSetWithDerivatives.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
|
87
src/math/math_FunctionSetWithDerivatives.hxx
Normal file
87
src/math/math_FunctionSetWithDerivatives.hxx
Normal file
@@ -0,0 +1,87 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionSetWithDerivatives_HeaderFile
|
||||
#define _math_FunctionSetWithDerivatives_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <math_FunctionSet.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
//! This abstract class describes the virtual functions associated
|
||||
//! with a set of N Functions each of M independant variables.
|
||||
class math_FunctionSetWithDerivatives : public math_FunctionSet
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Returns the number of variables of the function.
|
||||
Standard_EXPORT virtual Standard_Integer NbVariables() const = 0;
|
||||
|
||||
//! Returns the number of equations of the function.
|
||||
Standard_EXPORT virtual Standard_Integer NbEquations() const = 0;
|
||||
|
||||
//! Computes the values <F> of the Functions for the
|
||||
//! variable <X>.
|
||||
//! Returns True if the computation was done successfully,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Value (const math_Vector& X, math_Vector& F) = 0;
|
||||
|
||||
//! Returns the values <D> of the derivatives for the
|
||||
//! variable <X>.
|
||||
//! Returns True if the computation was done successfully,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Derivatives (const math_Vector& X, math_Matrix& D) = 0;
|
||||
|
||||
//! returns the values <F> of the functions and the derivatives
|
||||
//! <D> for the variable <X>.
|
||||
//! Returns True if the computation was done successfully,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X, math_Vector& F, math_Matrix& D) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionSetWithDerivatives_HeaderFile
|
@@ -1,51 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent Painnot
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class FunctionWithDerivative from math
|
||||
---Purpose:
|
||||
-- This abstract class describes the virtual functions associated with
|
||||
-- a function of a single variable for which the first derivative is
|
||||
-- available.
|
||||
|
||||
inherits Function
|
||||
|
||||
is
|
||||
Value(me: in out; X: Real; F: out Real)
|
||||
---Purpose: Computes the value <F>of the function for the variable <X>.
|
||||
-- Returns True if the calculation were successfully done,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
Derivative(me: in out; X: Real; D: out Real)
|
||||
---Purpose: Computes the derivative <D> of the function
|
||||
-- for the variable <X>.
|
||||
-- Returns True if the calculation were successfully done,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
Values(me: in out; X: Real; F, D: out Real)
|
||||
---Purpose: Computes the value <F> and the derivative <D> of the
|
||||
-- function for the variable <X>.
|
||||
-- Returns True if the calculation were successfully done,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
---C++: alias " Standard_EXPORT virtual ~math_FunctionWithDerivative();"
|
||||
|
||||
end FunctionWithDerivative;
|
@@ -12,7 +12,8 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_FunctionWithDerivative.ixx>
|
||||
|
||||
#include <math_FunctionWithDerivative.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ~math_FunctionWithDerivative
|
||||
|
81
src/math/math_FunctionWithDerivative.hxx
Normal file
81
src/math/math_FunctionWithDerivative.hxx
Normal file
@@ -0,0 +1,81 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent Painnot
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_FunctionWithDerivative_HeaderFile
|
||||
#define _math_FunctionWithDerivative_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <math_Function.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
|
||||
|
||||
|
||||
//! This abstract class describes the virtual functions associated with
|
||||
//! a function of a single variable for which the first derivative is
|
||||
//! available.
|
||||
class math_FunctionWithDerivative : public math_Function
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Computes the value <F>of the function for the variable <X>.
|
||||
//! Returns True if the calculation were successfully done,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Value (const Standard_Real X, Standard_Real& F) = 0;
|
||||
|
||||
//! Computes the derivative <D> of the function
|
||||
//! for the variable <X>.
|
||||
//! Returns True if the calculation were successfully done,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Derivative (const Standard_Real X, Standard_Real& D) = 0;
|
||||
|
||||
//! Computes the value <F> and the derivative <D> of the
|
||||
//! function for the variable <X>.
|
||||
//! Returns True if the calculation were successfully done,
|
||||
//! False otherwise.
|
||||
Standard_EXPORT virtual Standard_Boolean Values (const Standard_Real X, Standard_Real& F, Standard_Real& D) = 0;
|
||||
Standard_EXPORT virtual ~math_FunctionWithDerivative();
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_FunctionWithDerivative_HeaderFile
|
@@ -1,128 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class Gauss from math
|
||||
---Purpose:
|
||||
-- This class implements the Gauss LU decomposition (Crout algorithm)
|
||||
-- with partial pivoting (rows interchange) of a square matrix and
|
||||
-- the different possible derived calculation :
|
||||
-- - solution of a set of linear equations.
|
||||
-- - inverse of a matrix.
|
||||
-- - determinant of a matrix.
|
||||
|
||||
|
||||
uses Vector from math,
|
||||
IntegerVector from math,
|
||||
Matrix from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotSquare from math,
|
||||
DimensionError from Standard,
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(A: Matrix; MinPivot: Real = 1.0e-20)
|
||||
---Purpose:
|
||||
-- Given an input n X n matrix A this constructor performs its LU
|
||||
-- decomposition with partial pivoting (interchange of rows).
|
||||
-- This LU decomposition is stored internally and may be used to
|
||||
-- do subsequent calculation.
|
||||
-- If the largest pivot found is less than MinPivot the matrix A is
|
||||
-- considered as singular.
|
||||
-- Exception NotSquare is raised if A is not a square matrix.
|
||||
|
||||
returns Gauss
|
||||
raises NotSquare;
|
||||
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Solve(me; B: Vector; X : out Vector)
|
||||
---Purpose:
|
||||
-- Given the input Vector B this routine returns the solution X of the set
|
||||
-- of linear equations A . X = B.
|
||||
-- Exception NotDone is raised if the decomposition of A was not done
|
||||
-- successfully.
|
||||
-- Exception DimensionError is raised if the range of B is not
|
||||
-- equal to the number of rows of A.
|
||||
|
||||
raises NotDone,
|
||||
DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Solve(me; B: in out Vector)
|
||||
---Purpose:
|
||||
-- Given the input Vector B this routine solves the set of linear
|
||||
-- equations A . X = B. B is replaced by the vector solution X.
|
||||
-- Exception NotDone is raised if the decomposition of A was not done
|
||||
-- successfully.
|
||||
-- Exception DimensionError is raised if the range of B is not
|
||||
-- equal to the number of rows of A.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Determinant(me)
|
||||
---Purpose:
|
||||
-- This routine returns the value of the determinant of the previously LU
|
||||
-- decomposed matrix A.
|
||||
-- Exception NotDone may be raised if the decomposition of A was not done
|
||||
-- successfully, zero is returned if the matrix A was considered as singular.
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Invert(me; Inv: out Matrix)
|
||||
---Purpose:
|
||||
-- This routine outputs Inv the inverse of the previously LU decomposed
|
||||
-- matrix A.
|
||||
-- Exception DimensionError is raised if the ranges of B are not
|
||||
-- equal to the ranges of A.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
Singular: Boolean is protected;
|
||||
LU: Matrix is protected;
|
||||
Index: IntegerVector is protected;
|
||||
D: Real is protected;
|
||||
|
||||
|
||||
|
||||
end Gauss;
|
@@ -16,15 +16,16 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_Gauss.ixx>
|
||||
#include <math_Gauss.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_NotSquare.hxx>
|
||||
#include <math_Recipes.hxx>
|
||||
|
||||
#include <math_NotSquare.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_Gauss::math_Gauss(const math_Matrix& A,
|
||||
const Standard_Real MinPivot)
|
||||
|
129
src/math/math_Gauss.hxx
Normal file
129
src/math/math_Gauss.hxx
Normal file
@@ -0,0 +1,129 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_Gauss_HeaderFile
|
||||
#define _math_Gauss_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class math_NotSquare;
|
||||
class Standard_DimensionError;
|
||||
class StdFail_NotDone;
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
|
||||
//! This class implements the Gauss LU decomposition (Crout algorithm)
|
||||
//! with partial pivoting (rows interchange) of a square matrix and
|
||||
//! the different possible derived calculation :
|
||||
//! - solution of a set of linear equations.
|
||||
//! - inverse of a matrix.
|
||||
//! - determinant of a matrix.
|
||||
class math_Gauss
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! Given an input n X n matrix A this constructor performs its LU
|
||||
//! decomposition with partial pivoting (interchange of rows).
|
||||
//! This LU decomposition is stored internally and may be used to
|
||||
//! do subsequent calculation.
|
||||
//! If the largest pivot found is less than MinPivot the matrix A is
|
||||
//! considered as singular.
|
||||
//! Exception NotSquare is raised if A is not a square matrix.
|
||||
Standard_EXPORT math_Gauss(const math_Matrix& A, const Standard_Real MinPivot = 1.0e-20);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
|
||||
//! Given the input Vector B this routine returns the solution X of the set
|
||||
//! of linear equations A . X = B.
|
||||
//! Exception NotDone is raised if the decomposition of A was not done
|
||||
//! successfully.
|
||||
//! Exception DimensionError is raised if the range of B is not
|
||||
//! equal to the number of rows of A.
|
||||
Standard_EXPORT void Solve (const math_Vector& B, math_Vector& X) const;
|
||||
|
||||
|
||||
//! Given the input Vector B this routine solves the set of linear
|
||||
//! equations A . X = B. B is replaced by the vector solution X.
|
||||
//! Exception NotDone is raised if the decomposition of A was not done
|
||||
//! successfully.
|
||||
//! Exception DimensionError is raised if the range of B is not
|
||||
//! equal to the number of rows of A.
|
||||
Standard_EXPORT void Solve (math_Vector& B) const;
|
||||
|
||||
|
||||
//! This routine returns the value of the determinant of the previously LU
|
||||
//! decomposed matrix A.
|
||||
//! Exception NotDone may be raised if the decomposition of A was not done
|
||||
//! successfully, zero is returned if the matrix A was considered as singular.
|
||||
Standard_EXPORT Standard_Real Determinant() const;
|
||||
|
||||
|
||||
//! This routine outputs Inv the inverse of the previously LU decomposed
|
||||
//! matrix A.
|
||||
//! Exception DimensionError is raised if the ranges of B are not
|
||||
//! equal to the ranges of A.
|
||||
Standard_EXPORT void Invert (math_Matrix& Inv) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Singular;
|
||||
math_Matrix LU;
|
||||
math_IntegerVector Index;
|
||||
Standard_Real D;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_Gauss.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_Gauss_HeaderFile
|
@@ -1,88 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class GaussLeastSquare from math
|
||||
---Purpose:
|
||||
-- This class implements the least square solution of a set of
|
||||
-- n linear equations of m unknowns (n >= m) using the gauss LU
|
||||
-- decomposition algorithm.
|
||||
-- This algorithm is more likely subject to numerical instability
|
||||
-- than math_SVD.
|
||||
|
||||
|
||||
uses Matrix from math,
|
||||
Vector from math,
|
||||
IntegerVector from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail,
|
||||
DimensionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(A: Matrix; MinPivot: Real = 1.0e-20)
|
||||
---Purpose: Given an input n X m matrix A with n >= m this constructor
|
||||
-- performs the LU decomposition with partial pivoting
|
||||
-- (interchange of rows) of the matrix AA = A.Transposed() * A;
|
||||
-- This LU decomposition is stored internally and may be used
|
||||
-- to do subsequent calculation.
|
||||
-- If the largest pivot found is less than MinPivot the matrix <A>
|
||||
-- is considered as singular.
|
||||
|
||||
returns GaussLeastSquare;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.e
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Solve(me; B: in Vector; X: out Vector)
|
||||
---Purpose: Given the input Vector <B> this routine solves the set
|
||||
-- of linear equations A . X = B.
|
||||
-- Exception NotDone is raised if the decomposition of A was
|
||||
-- not done successfully.
|
||||
-- Exception DimensionError is raised if the range of B Inv is
|
||||
-- not equal to the rowrange of A.
|
||||
-- Exception DimensionError is raised if the range of X Inv is
|
||||
-- not equal to the colrange of A.
|
||||
|
||||
raises NotDone,
|
||||
DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
Singular: Boolean is protected;
|
||||
LU: Matrix is protected;
|
||||
A2 : Matrix is protected;
|
||||
Index: IntegerVector is protected;
|
||||
D: Real is protected;
|
||||
|
||||
|
||||
end GaussLeastSquare;
|
@@ -16,14 +16,14 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_GaussLeastSquare.ixx>
|
||||
#include <math_GaussLeastSquare.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_Recipes.hxx>
|
||||
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_GaussLeastSquare::math_GaussLeastSquare (const math_Matrix& A,
|
||||
const Standard_Real MinPivot) :
|
||||
|
105
src/math/math_GaussLeastSquare.hxx
Normal file
105
src/math/math_GaussLeastSquare.hxx
Normal file
@@ -0,0 +1,105 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_GaussLeastSquare_HeaderFile
|
||||
#define _math_GaussLeastSquare_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class Standard_DimensionError;
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
|
||||
//! This class implements the least square solution of a set of
|
||||
//! n linear equations of m unknowns (n >= m) using the gauss LU
|
||||
//! decomposition algorithm.
|
||||
//! This algorithm is more likely subject to numerical instability
|
||||
//! than math_SVD.
|
||||
class math_GaussLeastSquare
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Given an input n X m matrix A with n >= m this constructor
|
||||
//! performs the LU decomposition with partial pivoting
|
||||
//! (interchange of rows) of the matrix AA = A.Transposed() * A;
|
||||
//! This LU decomposition is stored internally and may be used
|
||||
//! to do subsequent calculation.
|
||||
//! If the largest pivot found is less than MinPivot the matrix <A>
|
||||
//! is considered as singular.
|
||||
Standard_EXPORT math_GaussLeastSquare(const math_Matrix& A, const Standard_Real MinPivot = 1.0e-20);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.e
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Given the input Vector <B> this routine solves the set
|
||||
//! of linear equations A . X = B.
|
||||
//! Exception NotDone is raised if the decomposition of A was
|
||||
//! not done successfully.
|
||||
//! Exception DimensionError is raised if the range of B Inv is
|
||||
//! not equal to the rowrange of A.
|
||||
//! Exception DimensionError is raised if the range of X Inv is
|
||||
//! not equal to the colrange of A.
|
||||
Standard_EXPORT void Solve (const math_Vector& B, math_Vector& X) const;
|
||||
|
||||
//! Prints on the stream o information on the current state
|
||||
//! of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Singular;
|
||||
math_Matrix LU;
|
||||
math_Matrix A2;
|
||||
math_IntegerVector Index;
|
||||
Standard_Real D;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_GaussLeastSquare.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_GaussLeastSquare_HeaderFile
|
@@ -1,70 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class GaussMultipleIntegration from math
|
||||
---Purpose:
|
||||
-- This class implements the integration of a function of multiple
|
||||
-- variables between the parameter bounds Lower[a..b] and Upper[a..b].
|
||||
-- Warning: Each element of Order must be inferior or equal to 61.
|
||||
|
||||
|
||||
uses Vector from math,
|
||||
IntegerVector from math,
|
||||
MultipleVarFunction from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out MultipleVarFunction; Lower, Upper: Vector;
|
||||
Order: IntegerVector)
|
||||
---Purpose:
|
||||
-- The Gauss-Legendre integration with Order = points of
|
||||
-- integration for each unknow, is done on the function F
|
||||
-- between the bounds Lower and Upper.
|
||||
|
||||
returns GaussMultipleIntegration;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: returns True if all has been correctly done.
|
||||
---C++: inline
|
||||
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns the value of the integral.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints information on the current state of the object.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Val: Real;
|
||||
Done: Boolean;
|
||||
|
||||
end GaussMultipleIntegration;
|
@@ -37,14 +37,16 @@ de Gauss.
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_GaussMultipleIntegration.ixx>
|
||||
#include <math.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_GaussMultipleIntegration.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_MultipleVarFunction.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
class IntegrationFunction {
|
||||
|
||||
|
85
src/math/math_GaussMultipleIntegration.hxx
Normal file
85
src/math/math_GaussMultipleIntegration.hxx
Normal file
@@ -0,0 +1,85 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_GaussMultipleIntegration_HeaderFile
|
||||
#define _math_GaussMultipleIntegration_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_MultipleVarFunction;
|
||||
|
||||
|
||||
|
||||
//! This class implements the integration of a function of multiple
|
||||
//! variables between the parameter bounds Lower[a..b] and Upper[a..b].
|
||||
//! Warning: Each element of Order must be inferior or equal to 61.
|
||||
class math_GaussMultipleIntegration
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! The Gauss-Legendre integration with Order = points of
|
||||
//! integration for each unknow, is done on the function F
|
||||
//! between the bounds Lower and Upper.
|
||||
Standard_EXPORT math_GaussMultipleIntegration(math_MultipleVarFunction& F, const math_Vector& Lower, const math_Vector& Upper, const math_IntegerVector& Order);
|
||||
|
||||
//! returns True if all has been correctly done.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the value of the integral.
|
||||
Standard_Real Value() const;
|
||||
|
||||
//! Prints information on the current state of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Real Val;
|
||||
Standard_Boolean Done;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_GaussMultipleIntegration.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_GaussMultipleIntegration_HeaderFile
|
@@ -1,72 +0,0 @@
|
||||
-- Created on: 1996-01-22
|
||||
-- Created by: Philippe MANGIN
|
||||
-- Copyright (c) 1996-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class GaussSetIntegration from math
|
||||
---Purpose: -- This class implements the integration of a set of N
|
||||
-- functions of M variables variables between the
|
||||
-- parameter bounds Lower[a..b] and Upper[a..b].
|
||||
-- Warning: - The case M>1 is not implemented.
|
||||
|
||||
|
||||
uses Vector from math,
|
||||
IntegerVector from math,
|
||||
FunctionSet from math,
|
||||
OStream from Standard,
|
||||
NotDone from StdFail
|
||||
|
||||
raises NotDone, NotImplemented
|
||||
|
||||
is
|
||||
|
||||
Create(F: in out FunctionSet; Lower, Upper: Vector;
|
||||
Order: IntegerVector)
|
||||
---Purpose:
|
||||
-- The Gauss-Legendre integration with Order = points of
|
||||
-- integration for each unknow, is done on the function F
|
||||
-- between the bounds Lower and Upper.
|
||||
returns GaussSetIntegration
|
||||
raises NotImplemented;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: returns True if all has been correctly done.
|
||||
---C++: inline
|
||||
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns the value of the integral.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints information on the current state of the object.
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Val: Vector;
|
||||
Done: Boolean;
|
||||
|
||||
end GaussSetIntegration;
|
@@ -16,13 +16,15 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_GaussSetIntegration.ixx>
|
||||
#include <math.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_FunctionSet.hxx>
|
||||
|
||||
#include <math_GaussSetIntegration.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_GaussSetIntegration::math_GaussSetIntegration(math_FunctionSet& F,
|
||||
const math_Vector& Lower,
|
||||
|
85
src/math/math_GaussSetIntegration.hxx
Normal file
85
src/math/math_GaussSetIntegration.hxx
Normal file
@@ -0,0 +1,85 @@
|
||||
// Created on: 1996-01-22
|
||||
// Created by: Philippe MANGIN
|
||||
// Copyright (c) 1996-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_GaussSetIntegration_HeaderFile
|
||||
#define _math_GaussSetIntegration_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_IntegerVector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class Standard_NotImplemented;
|
||||
class math_FunctionSet;
|
||||
|
||||
|
||||
//! -- This class implements the integration of a set of N
|
||||
//! functions of M variables variables between the
|
||||
//! parameter bounds Lower[a..b] and Upper[a..b].
|
||||
//! Warning: - The case M>1 is not implemented.
|
||||
class math_GaussSetIntegration
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! The Gauss-Legendre integration with Order = points of
|
||||
//! integration for each unknow, is done on the function F
|
||||
//! between the bounds Lower and Upper.
|
||||
Standard_EXPORT math_GaussSetIntegration(math_FunctionSet& F, const math_Vector& Lower, const math_Vector& Upper, const math_IntegerVector& Order);
|
||||
|
||||
//! returns True if all has been correctly done.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the value of the integral.
|
||||
const math_Vector& Value() const;
|
||||
|
||||
//! Prints information on the current state of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
math_Vector Val;
|
||||
Standard_Boolean Done;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_GaussSetIntegration.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_GaussSetIntegration_HeaderFile
|
@@ -1,80 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class GaussSingleIntegration from math
|
||||
---Purpose:
|
||||
-- This class implements the integration of a function of a single variable
|
||||
-- between the parameter bounds Lower and Upper.
|
||||
-- Warning: Order must be inferior or equal to 61.
|
||||
|
||||
|
||||
uses Function from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
Create
|
||||
returns GaussSingleIntegration;
|
||||
|
||||
Create(F: in out Function; Lower, Upper: Real; Order: Integer)
|
||||
---Purpose:
|
||||
-- The Gauss-Legendre integration with N = Order points of integration,
|
||||
-- is done on the function F between the bounds Lower and Upper.
|
||||
|
||||
returns GaussSingleIntegration;
|
||||
|
||||
Create(F: in out Function; Lower, Upper: Real; Order: Integer; Tol: Real)
|
||||
---Purpose:
|
||||
-- The Gauss-Legendre integration with N = Order points of integration and
|
||||
-- given tolerance = Tol is done on the function F between the bounds
|
||||
-- Lower and Upper.
|
||||
|
||||
returns GaussSingleIntegration;
|
||||
|
||||
Perform(me: in out; F: in out Function; Lower, Upper: Real; Order: Integer)
|
||||
---Purpose: perfoms actual computation
|
||||
is private;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: returns True if all has been correctly done.
|
||||
---C++: inline
|
||||
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns the value of the integral.
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints information on the current state of the object.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Val: Real;
|
||||
Done: Boolean;
|
||||
|
||||
end GaussSingleIntegration;
|
@@ -41,13 +41,14 @@ Etapes du calcul:
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_GaussSingleIntegration.ixx>
|
||||
|
||||
#include <math.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <math_GaussSingleIntegration.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_GaussSingleIntegration::math_GaussSingleIntegration() : Done(Standard_False)
|
||||
{
|
||||
|
94
src/math/math_GaussSingleIntegration.hxx
Normal file
94
src/math/math_GaussSingleIntegration.hxx
Normal file
@@ -0,0 +1,94 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_GaussSingleIntegration_HeaderFile
|
||||
#define _math_GaussSingleIntegration_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_Function;
|
||||
|
||||
|
||||
|
||||
//! This class implements the integration of a function of a single variable
|
||||
//! between the parameter bounds Lower and Upper.
|
||||
//! Warning: Order must be inferior or equal to 61.
|
||||
class math_GaussSingleIntegration
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT math_GaussSingleIntegration();
|
||||
|
||||
|
||||
//! The Gauss-Legendre integration with N = Order points of integration,
|
||||
//! is done on the function F between the bounds Lower and Upper.
|
||||
Standard_EXPORT math_GaussSingleIntegration(math_Function& F, const Standard_Real Lower, const Standard_Real Upper, const Standard_Integer Order);
|
||||
|
||||
|
||||
//! The Gauss-Legendre integration with N = Order points of integration and
|
||||
//! given tolerance = Tol is done on the function F between the bounds
|
||||
//! Lower and Upper.
|
||||
Standard_EXPORT math_GaussSingleIntegration(math_Function& F, const Standard_Real Lower, const Standard_Real Upper, const Standard_Integer Order, const Standard_Real Tol);
|
||||
|
||||
//! returns True if all has been correctly done.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! returns the value of the integral.
|
||||
Standard_Real Value() const;
|
||||
|
||||
//! Prints information on the current state of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//! perfoms actual computation
|
||||
Standard_EXPORT void Perform (math_Function& F, const Standard_Real Lower, const Standard_Real Upper, const Standard_Integer Order);
|
||||
|
||||
|
||||
Standard_Real Val;
|
||||
Standard_Boolean Done;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_GaussSingleIntegration.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_GaussSingleIntegration_HeaderFile
|
@@ -1,136 +0,0 @@
|
||||
-- Created on: 1991-08-07
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class Householder from math
|
||||
|
||||
---Purpose: This class implements the least square solution of a set of
|
||||
-- linear equations of m unknowns (n >= m) using the Householder
|
||||
-- method. It solves A.X = B.
|
||||
-- This algorithm has more numerical stability than
|
||||
-- GaussLeastSquare but is longer.
|
||||
-- It must be used if the matrix is singular or nearly singular.
|
||||
-- It is about 16% longer than GaussLeastSquare if there is only
|
||||
-- one member B to solve.
|
||||
-- It is about 30% longer if there are twenty B members to solve.
|
||||
|
||||
uses Matrix from math,
|
||||
Vector from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail,
|
||||
OutOfRange from Standard,
|
||||
DimensionError from Standard,
|
||||
ConstructionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create(A, B: Matrix; EPS: Real = 1.0e-20)
|
||||
---Purpose: Given an input matrix A with n>= m, given an input matrix B
|
||||
-- this constructor performs the least square resolution of
|
||||
-- the set of linear equations A.X = B for each column of B.
|
||||
-- If a column norm is less than EPS, the resolution can't
|
||||
-- be done.
|
||||
-- Exception DimensionError is raised if the row number of B
|
||||
-- is different from the A row number.
|
||||
|
||||
returns Householder
|
||||
raises DimensionError;
|
||||
|
||||
Create(A, B: Matrix; lowerArow, upperArow, lowerAcol, upperAcol: Integer;
|
||||
EPS: Real = 1.0e-20)
|
||||
---Purpose: Given an input matrix A with n>= m, given an input matrix B
|
||||
-- this constructor performs the least square resolution of
|
||||
-- the set of linear equations A.X = B for each column of B.
|
||||
-- If a column norm is less than EPS, the resolution can't
|
||||
-- be done.
|
||||
-- Exception DimensionError is raised if the row number of B
|
||||
-- is different from the A row number.
|
||||
|
||||
returns Householder
|
||||
raises DimensionError;
|
||||
|
||||
|
||||
Create(A: Matrix; B: Vector; EPS: Real = 1.0e-20)
|
||||
---Purpose: Given an input matrix A with n>= m, given an input vector B
|
||||
-- this constructor performs the least square resolution of
|
||||
-- the set of linear equations A.X = B.
|
||||
-- If a column norm is less than EPS, the resolution can't
|
||||
-- be done.
|
||||
-- Exception DimensionError is raised if the length of B
|
||||
-- is different from the A row number.
|
||||
|
||||
returns Householder
|
||||
raises DimensionError;
|
||||
|
||||
|
||||
Perform(me: in out; A, B: Matrix; EPS: Real)
|
||||
---Purpose: This method is used internally for each constructor
|
||||
-- above and can't be used directly.
|
||||
|
||||
is static protected;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Value(me; sol : out Vector; Index: Integer = 1)
|
||||
---Purpose: Given the integer Index, this routine returns the
|
||||
-- corresponding least square solution sol.
|
||||
-- Exception NotDone is raised if the resolution has not be
|
||||
-- done.
|
||||
-- Exception OutOfRange is raised if Index <=0 or
|
||||
-- Index is more than the number of columns of B.
|
||||
---C++: inline
|
||||
|
||||
raises NotDone, OutOfRange
|
||||
is static;
|
||||
|
||||
|
||||
AllValues(me)
|
||||
---Purpose: Returns the matrix sol of all the solutions of the system
|
||||
-- A.X = B.
|
||||
-- Exception NotDone is raised is the resolution has not be
|
||||
-- done.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
returns Matrix
|
||||
raises NotDone, ConstructionError
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints informations on the current state of the object.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Sol: Matrix;
|
||||
Q: Matrix;
|
||||
Done: Boolean;
|
||||
mylowerArow: Integer;
|
||||
myupperArow: Integer;
|
||||
mylowerAcol: Integer;
|
||||
myupperAcol: Integer;
|
||||
|
||||
end Householder;
|
@@ -16,11 +16,15 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_Householder.ixx>
|
||||
#include <math_Householder.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
// Cette classe decrit la methode de Householder qui transforme A en un
|
||||
// produit de matrice orthogonale par une triangulaire superieure. Les seconds
|
||||
@@ -29,12 +33,10 @@
|
||||
// 90 du livre "Introduction a l'analyse numerique matricielle et a
|
||||
// l'optimisation." par P.G. CIARLET, edition MASSON. Les secondes
|
||||
// references sont celles du sous-programme HOUSEO d'Euclid.
|
||||
|
||||
// A la difference du sous-programme Houseo, la premiere colonne n'est pas
|
||||
// traitee separement. Les tests effectues ont montre que le code effectue
|
||||
// specialement pour celle-ci etait plus long qu'une simple recopie. C'est
|
||||
// donc cette solution de recopie initiale qui a ete retenue.
|
||||
|
||||
math_Householder::math_Householder(const math_Matrix& A, const math_Vector& B,
|
||||
const Standard_Real EPS):
|
||||
Sol(1, A.ColNumber(), 1, 1),
|
||||
|
135
src/math/math_Householder.hxx
Normal file
135
src/math/math_Householder.hxx
Normal file
@@ -0,0 +1,135 @@
|
||||
// Created on: 1991-08-07
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_Householder_HeaderFile
|
||||
#define _math_Householder_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <math_Matrix.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class Standard_OutOfRange;
|
||||
class Standard_DimensionError;
|
||||
class Standard_ConstructionError;
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
//! This class implements the least square solution of a set of
|
||||
//! linear equations of m unknowns (n >= m) using the Householder
|
||||
//! method. It solves A.X = B.
|
||||
//! This algorithm has more numerical stability than
|
||||
//! GaussLeastSquare but is longer.
|
||||
//! It must be used if the matrix is singular or nearly singular.
|
||||
//! It is about 16% longer than GaussLeastSquare if there is only
|
||||
//! one member B to solve.
|
||||
//! It is about 30% longer if there are twenty B members to solve.
|
||||
class math_Householder
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Given an input matrix A with n>= m, given an input matrix B
|
||||
//! this constructor performs the least square resolution of
|
||||
//! the set of linear equations A.X = B for each column of B.
|
||||
//! If a column norm is less than EPS, the resolution can't
|
||||
//! be done.
|
||||
//! Exception DimensionError is raised if the row number of B
|
||||
//! is different from the A row number.
|
||||
Standard_EXPORT math_Householder(const math_Matrix& A, const math_Matrix& B, const Standard_Real EPS = 1.0e-20);
|
||||
|
||||
//! Given an input matrix A with n>= m, given an input matrix B
|
||||
//! this constructor performs the least square resolution of
|
||||
//! the set of linear equations A.X = B for each column of B.
|
||||
//! If a column norm is less than EPS, the resolution can't
|
||||
//! be done.
|
||||
//! Exception DimensionError is raised if the row number of B
|
||||
//! is different from the A row number.
|
||||
Standard_EXPORT math_Householder(const math_Matrix& A, const math_Matrix& B, const Standard_Integer lowerArow, const Standard_Integer upperArow, const Standard_Integer lowerAcol, const Standard_Integer upperAcol, const Standard_Real EPS = 1.0e-20);
|
||||
|
||||
//! Given an input matrix A with n>= m, given an input vector B
|
||||
//! this constructor performs the least square resolution of
|
||||
//! the set of linear equations A.X = B.
|
||||
//! If a column norm is less than EPS, the resolution can't
|
||||
//! be done.
|
||||
//! Exception DimensionError is raised if the length of B
|
||||
//! is different from the A row number.
|
||||
Standard_EXPORT math_Householder(const math_Matrix& A, const math_Vector& B, const Standard_Real EPS = 1.0e-20);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Given the integer Index, this routine returns the
|
||||
//! corresponding least square solution sol.
|
||||
//! Exception NotDone is raised if the resolution has not be
|
||||
//! done.
|
||||
//! Exception OutOfRange is raised if Index <=0 or
|
||||
//! Index is more than the number of columns of B.
|
||||
void Value (math_Vector& sol, const Standard_Integer Index = 1) const;
|
||||
|
||||
//! Returns the matrix sol of all the solutions of the system
|
||||
//! A.X = B.
|
||||
//! Exception NotDone is raised is the resolution has not be
|
||||
//! done.
|
||||
const math_Matrix& AllValues() const;
|
||||
|
||||
//! Prints informations on the current state of the object.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//! This method is used internally for each constructor
|
||||
//! above and can't be used directly.
|
||||
Standard_EXPORT void Perform (const math_Matrix& A, const math_Matrix& B, const Standard_Real EPS);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
math_Matrix Sol;
|
||||
math_Matrix Q;
|
||||
Standard_Boolean Done;
|
||||
Standard_Integer mylowerArow;
|
||||
Standard_Integer myupperArow;
|
||||
Standard_Integer mylowerAcol;
|
||||
Standard_Integer myupperAcol;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_Householder.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_Householder_HeaderFile
|
@@ -1,103 +0,0 @@
|
||||
-- Created on: 1991-05-14
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class Jacobi from math
|
||||
---Purpose:
|
||||
-- This class implements the Jacobi method to find the eigenvalues and
|
||||
-- the eigenvectors of a real symmetric square matrix.
|
||||
-- A sort of eigenvalues is done.
|
||||
|
||||
uses Vector from math,
|
||||
Matrix from math,
|
||||
OStream from Standard
|
||||
|
||||
raises NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create(A: Matrix)
|
||||
---Purpose:
|
||||
-- Given a Real n X n matrix A, this constructor computes all its
|
||||
-- eigenvalues and eigenvectors using the Jacobi method.
|
||||
-- The exception NotSquare is raised if the matrix is not square.
|
||||
-- No verification that the matrix A is really symmetric is done.
|
||||
|
||||
returns Jacobi;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns true if the computations are successful, otherwise returns false.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Values(me)
|
||||
---Purpose: Returns the eigenvalues vector.
|
||||
-- Exception NotDone is raised if calculation is not done successfully.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Vector
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Value(me; Num: Integer)
|
||||
---Purpose: returns the eigenvalue number Num.
|
||||
-- Eigenvalues are in the range (1..n).
|
||||
-- Exception NotDone is raised if calculation is not done successfully.
|
||||
---C++: inline
|
||||
returns Real
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Vectors(me)
|
||||
---Purpose: returns the eigenvectors matrix.
|
||||
-- Exception NotDone is raised if calculation is not done successfully.
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
returns Matrix
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
Vector(me; Num: Integer; V : out Vector)
|
||||
---Purpose: Returns the eigenvector V of number Num.
|
||||
-- Eigenvectors are in the range (1..n).
|
||||
-- Exception NotDone is raised if calculation is not done successfully.
|
||||
---C++: inline
|
||||
raises NotDone
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints information on the current state of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
Done: Boolean;
|
||||
AA: Matrix;
|
||||
NbRotations: Integer;
|
||||
EigenValues: Vector;
|
||||
EigenVectors: Matrix;
|
||||
|
||||
end Jacobi;
|
@@ -16,12 +16,14 @@
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
#define No_Standard_DimensionError
|
||||
|
||||
//#endif
|
||||
|
||||
#include <math_Jacobi.ixx>
|
||||
|
||||
#include <math_Recipes.hxx>
|
||||
#include <math_Jacobi.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_NotSquare.hxx>
|
||||
#include <math_Recipes.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
math_Jacobi::math_Jacobi(const math_Matrix& A) : AA(1, A.RowNumber(),
|
||||
1, A.RowNumber()),
|
||||
|
106
src/math/math_Jacobi.hxx
Normal file
106
src/math/math_Jacobi.hxx
Normal file
@@ -0,0 +1,106 @@
|
||||
// Created on: 1991-05-14
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_Jacobi_HeaderFile
|
||||
#define _math_Jacobi_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_Matrix;
|
||||
|
||||
|
||||
|
||||
//! This class implements the Jacobi method to find the eigenvalues and
|
||||
//! the eigenvectors of a real symmetric square matrix.
|
||||
//! A sort of eigenvalues is done.
|
||||
class math_Jacobi
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! Given a Real n X n matrix A, this constructor computes all its
|
||||
//! eigenvalues and eigenvectors using the Jacobi method.
|
||||
//! The exception NotSquare is raised if the matrix is not square.
|
||||
//! No verification that the matrix A is really symmetric is done.
|
||||
Standard_EXPORT math_Jacobi(const math_Matrix& A);
|
||||
|
||||
//! Returns true if the computations are successful, otherwise returns false.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns the eigenvalues vector.
|
||||
//! Exception NotDone is raised if calculation is not done successfully.
|
||||
const math_Vector& Values() const;
|
||||
|
||||
//! returns the eigenvalue number Num.
|
||||
//! Eigenvalues are in the range (1..n).
|
||||
//! Exception NotDone is raised if calculation is not done successfully.
|
||||
Standard_Real Value (const Standard_Integer Num) const;
|
||||
|
||||
//! returns the eigenvectors matrix.
|
||||
//! Exception NotDone is raised if calculation is not done successfully.
|
||||
const math_Matrix& Vectors() const;
|
||||
|
||||
//! Returns the eigenvector V of number Num.
|
||||
//! Eigenvectors are in the range (1..n).
|
||||
//! Exception NotDone is raised if calculation is not done successfully.
|
||||
void Vector (const Standard_Integer Num, math_Vector& V) const;
|
||||
|
||||
//! Prints information on the current state of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean Done;
|
||||
math_Matrix AA;
|
||||
Standard_Integer NbRotations;
|
||||
math_Vector EigenValues;
|
||||
math_Matrix EigenVectors;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_Jacobi.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_Jacobi_HeaderFile
|
@@ -13,8 +13,8 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math.ixx>
|
||||
|
||||
#include <math.hxx>
|
||||
#include <math_ComputeKronrodPointsAndWeights.hxx>
|
||||
|
||||
Standard_Integer math::KronrodPointsMax()
|
||||
|
@@ -1,144 +0,0 @@
|
||||
-- Created on: 2005-12-08
|
||||
-- Created by: Sergey KHROMOV
|
||||
-- Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class KronrodSingleIntegration from math
|
||||
---Purpose: This class implements the Gauss-Kronrod method of
|
||||
-- integral computation.
|
||||
|
||||
uses
|
||||
|
||||
Function from math,
|
||||
Vector from math,
|
||||
Real from Standard,
|
||||
Integer from Standard,
|
||||
Boolean from Standard
|
||||
|
||||
raises
|
||||
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Purpose: An empty constructor.
|
||||
returns KronrodSingleIntegration;
|
||||
|
||||
Create(theFunction : in out Function from math;
|
||||
theLower : Real from Standard;
|
||||
theUpper : Real from Standard;
|
||||
theNbPnts : Integer from Standard)
|
||||
---Purpose: Constructor. Takes the function, the lower and upper bound
|
||||
-- values, the initial number of Kronrod points
|
||||
returns KronrodSingleIntegration;
|
||||
|
||||
Create(theFunction : in out Function from math;
|
||||
theLower : Real from Standard;
|
||||
theUpper : Real from Standard;
|
||||
theNbPnts : Integer from Standard;
|
||||
theTolerance: Real from Standard;
|
||||
theMaxNbIter: Integer from Standard)
|
||||
---Purpose: Constructor. Takes the function, the lower and upper bound
|
||||
-- values, the initial number of Kronrod points, the
|
||||
-- tolerance value and the maximal number of iterations as
|
||||
-- parameters.
|
||||
returns KronrodSingleIntegration;
|
||||
|
||||
Perform(me: in out; theFunction : in out Function from math;
|
||||
theLower : Real from Standard;
|
||||
theUpper : Real from Standard;
|
||||
theNbPnts : Integer from Standard);
|
||||
---Purpose: Computation of the integral. Takes the function,
|
||||
-- the lower and upper bound values, the initial number
|
||||
-- of Kronrod points, the relative tolerance value and the
|
||||
-- maximal number of iterations as parameters.
|
||||
-- theNbPnts should be odd and greater then or equal to 3.
|
||||
|
||||
Perform(me: in out; theFunction : in out Function from math;
|
||||
theLower : Real from Standard;
|
||||
theUpper : Real from Standard;
|
||||
theNbPnts : Integer from Standard;
|
||||
theTolerance: Real from Standard;
|
||||
theMaxNbIter: Integer from Standard);
|
||||
---Purpose: Computation of the integral. Takes the function,
|
||||
-- the lower and upper bound values, the initial number
|
||||
-- of Kronrod points, the relative tolerance value and the
|
||||
-- maximal number of iterations as parameters.
|
||||
-- theNbPnts should be odd and greater then or equal to 3.
|
||||
-- Note that theTolerance is relative, i.e. the criterion of
|
||||
-- solution reaching is:
|
||||
-- Abs(Kronrod - Gauss)/Abs(Kronrod) < theTolerance.
|
||||
-- theTolerance should be positive.
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns Standard_True if computation is performed
|
||||
-- successfully.
|
||||
---C++: inline
|
||||
returns Boolean from Standard;
|
||||
|
||||
Value(me)
|
||||
---Purpose: Returns the value of the integral.
|
||||
---C++: inline
|
||||
returns Real from Standard
|
||||
raises NotDone;
|
||||
|
||||
ErrorReached(me)
|
||||
---Purpose: Returns the value of the relative error reached.
|
||||
---C++: inline
|
||||
returns Real from Standard
|
||||
raises NotDone;
|
||||
|
||||
AbsolutError(me)
|
||||
---Purpose: Returns the value of the relative error reached.
|
||||
---C++: inline
|
||||
returns Real from Standard
|
||||
raises NotDone;
|
||||
|
||||
OrderReached(me)
|
||||
---Purpose: Returns the number of Kronrod points
|
||||
-- for which the result is computed.
|
||||
---C++: inline
|
||||
returns Integer from Standard
|
||||
raises NotDone;
|
||||
|
||||
NbIterReached(me)
|
||||
---Purpose: Returns the number of iterations
|
||||
-- that were made to compute result.
|
||||
---C++: inline
|
||||
returns Integer from Standard
|
||||
raises NotDone;
|
||||
|
||||
GKRule(myclass;
|
||||
theFunction : in out Function from math;
|
||||
theLower : Real from Standard;
|
||||
theUpper : Real from Standard;
|
||||
theGaussP : Vector from math;
|
||||
theGaussW : Vector from math;
|
||||
theKronrodP : Vector from math;
|
||||
theKronrodW : Vector from math;
|
||||
theValue : in out Real from Standard;
|
||||
theError : in out Real from Standard)
|
||||
|
||||
returns Boolean from Standard;
|
||||
|
||||
fields
|
||||
|
||||
myIsDone : Boolean from Standard;
|
||||
myValue : Real from Standard;
|
||||
myErrorReached : Real from Standard;
|
||||
myAbsolutError : Real from Standard;
|
||||
myNbPntsReached: Integer from Standard;
|
||||
myNbIterReached: Integer from Standard;
|
||||
|
||||
end KronrodSingleIntegration;
|
@@ -13,16 +13,17 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_KronrodSingleIntegration.ixx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
|
||||
#include <math.hxx>
|
||||
#include <math_Function.hxx>
|
||||
#include <math_KronrodSingleIntegration.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
|
||||
//==========================================================================
|
||||
//function : An empty constructor.
|
||||
//==========================================================================
|
||||
|
||||
math_KronrodSingleIntegration::math_KronrodSingleIntegration() :
|
||||
myIsDone(Standard_False),
|
||||
myValue(0.),
|
||||
|
124
src/math/math_KronrodSingleIntegration.hxx
Normal file
124
src/math/math_KronrodSingleIntegration.hxx
Normal file
@@ -0,0 +1,124 @@
|
||||
// Created on: 2005-12-08
|
||||
// Created by: Sergey KHROMOV
|
||||
// Copyright (c) 2005-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_KronrodSingleIntegration_HeaderFile
|
||||
#define _math_KronrodSingleIntegration_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
class StdFail_NotDone;
|
||||
class math_Function;
|
||||
|
||||
|
||||
//! This class implements the Gauss-Kronrod method of
|
||||
//! integral computation.
|
||||
class math_KronrodSingleIntegration
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! An empty constructor.
|
||||
Standard_EXPORT math_KronrodSingleIntegration();
|
||||
|
||||
//! Constructor. Takes the function, the lower and upper bound
|
||||
//! values, the initial number of Kronrod points
|
||||
Standard_EXPORT math_KronrodSingleIntegration(math_Function& theFunction, const Standard_Real theLower, const Standard_Real theUpper, const Standard_Integer theNbPnts);
|
||||
|
||||
//! Constructor. Takes the function, the lower and upper bound
|
||||
//! values, the initial number of Kronrod points, the
|
||||
//! tolerance value and the maximal number of iterations as
|
||||
//! parameters.
|
||||
Standard_EXPORT math_KronrodSingleIntegration(math_Function& theFunction, const Standard_Real theLower, const Standard_Real theUpper, const Standard_Integer theNbPnts, const Standard_Real theTolerance, const Standard_Integer theMaxNbIter);
|
||||
|
||||
//! Computation of the integral. Takes the function,
|
||||
//! the lower and upper bound values, the initial number
|
||||
//! of Kronrod points, the relative tolerance value and the
|
||||
//! maximal number of iterations as parameters.
|
||||
//! theNbPnts should be odd and greater then or equal to 3.
|
||||
Standard_EXPORT void Perform (math_Function& theFunction, const Standard_Real theLower, const Standard_Real theUpper, const Standard_Integer theNbPnts);
|
||||
|
||||
//! Computation of the integral. Takes the function,
|
||||
//! the lower and upper bound values, the initial number
|
||||
//! of Kronrod points, the relative tolerance value and the
|
||||
//! maximal number of iterations as parameters.
|
||||
//! theNbPnts should be odd and greater then or equal to 3.
|
||||
//! Note that theTolerance is relative, i.e. the criterion of
|
||||
//! solution reaching is:
|
||||
//! Abs(Kronrod - Gauss)/Abs(Kronrod) < theTolerance.
|
||||
//! theTolerance should be positive.
|
||||
Standard_EXPORT void Perform (math_Function& theFunction, const Standard_Real theLower, const Standard_Real theUpper, const Standard_Integer theNbPnts, const Standard_Real theTolerance, const Standard_Integer theMaxNbIter);
|
||||
|
||||
//! Returns Standard_True if computation is performed
|
||||
//! successfully.
|
||||
Standard_Boolean IsDone() const;
|
||||
|
||||
//! Returns the value of the integral.
|
||||
Standard_Real Value() const;
|
||||
|
||||
//! Returns the value of the relative error reached.
|
||||
Standard_Real ErrorReached() const;
|
||||
|
||||
//! Returns the value of the relative error reached.
|
||||
Standard_Real AbsolutError() const;
|
||||
|
||||
//! Returns the number of Kronrod points
|
||||
//! for which the result is computed.
|
||||
Standard_Integer OrderReached() const;
|
||||
|
||||
//! Returns the number of iterations
|
||||
//! that were made to compute result.
|
||||
Standard_Integer NbIterReached() const;
|
||||
|
||||
Standard_EXPORT static Standard_Boolean GKRule (math_Function& theFunction, const Standard_Real theLower, const Standard_Real theUpper, const math_Vector& theGaussP, const math_Vector& theGaussW, const math_Vector& theKronrodP, const math_Vector& theKronrodW, Standard_Real& theValue, Standard_Real& theError);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Boolean myIsDone;
|
||||
Standard_Real myValue;
|
||||
Standard_Real myErrorReached;
|
||||
Standard_Real myAbsolutError;
|
||||
Standard_Integer myNbPntsReached;
|
||||
Standard_Integer myNbIterReached;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_KronrodSingleIntegration.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_KronrodSingleIntegration_HeaderFile
|
@@ -1,571 +0,0 @@
|
||||
-- Created on: 1991-05-07
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class Matrix from math
|
||||
|
||||
---Purpose: This class implements the real matrix abstract data type.
|
||||
-- Matrixes can have an arbitrary range which must be defined
|
||||
-- at the declaration and cannot be changed after this declaration
|
||||
-- math_Matrix(-3,5,2,4); //a vector with range [-3..5, 2..4]
|
||||
-- Matrix values may be initialized and
|
||||
-- retrieved using indexes which must lie within the range
|
||||
-- of definition of the matrix.
|
||||
-- Matrix objects follow "value semantics", that is, they
|
||||
-- cannot be shared and are copied through assignment
|
||||
-- Matrices are copied through assignement:
|
||||
-- math_Matrix M2(1, 9, 1, 3);
|
||||
-- ...
|
||||
-- M2 = M1;
|
||||
-- M1(1) = 2.0;//the matrix M2 will not be modified.
|
||||
--
|
||||
-- The exception RangeError is raised when trying to access
|
||||
-- outside the range of a matrix :
|
||||
-- M1(11, 1)=0.0// --> will raise RangeError.
|
||||
--
|
||||
-- The exception DimensionError is raised when the dimensions of
|
||||
-- two matrices or vectors are not compatible.
|
||||
-- math_Matrix M3(1, 2, 1, 2);
|
||||
-- M3 = M1; // will raise DimensionError
|
||||
-- M1.Add(M3) // --> will raise DimensionError.
|
||||
-- A Matrix can be constructed with a a pointer to "c array".
|
||||
-- It allows to carry the bounds inside the matrix.
|
||||
-- Exemple :
|
||||
-- Standard_Real tab1[10][20];
|
||||
-- Standard_Real tab2[200];
|
||||
--
|
||||
-- math_Matrix A (tab1[0][0], 1, 10, 1, 20);
|
||||
-- math_Matrix B (tab2[0], 1, 10, 1, 20);
|
||||
|
||||
|
||||
uses Vector from math,
|
||||
DoubleTab from math,
|
||||
OStream from Standard
|
||||
|
||||
raises DimensionError from Standard, RangeError from Standard,
|
||||
DivideByZero from Standard, NotSquare from math,
|
||||
SingularMatrix from math
|
||||
|
||||
is
|
||||
|
||||
Create(LowerRow, UpperRow, LowerCol, UpperCol: Integer)
|
||||
---Purpose: Constructs a non-initialized matrix of range [LowerRow..UpperRow,
|
||||
-- LowerCol..UpperCol]
|
||||
-- For the constructed matrix:
|
||||
-- - LowerRow and UpperRow are the indexes of the
|
||||
-- lower and upper bounds of a row, and
|
||||
-- - LowerCol and UpperCol are the indexes of the
|
||||
-- lower and upper bounds of a column.
|
||||
returns Matrix
|
||||
raises RangeError;
|
||||
|
||||
Create(LowerRow, UpperRow, LowerCol, UpperCol: Integer;
|
||||
InitialValue : Real)
|
||||
---Purpose: constructs a non-initialized matrix of range [LowerRow..UpperRow,
|
||||
-- LowerCol..UpperCol]
|
||||
-- whose values are all initialized with the value InitialValue.
|
||||
returns Matrix
|
||||
raises RangeError;
|
||||
|
||||
|
||||
Create(Tab : Address;
|
||||
LowerRow, UpperRow, LowerCol, UpperCol: Integer)
|
||||
---Purpose: constructs a matrix of range [LowerRow..UpperRow,
|
||||
-- LowerCol..UpperCol]
|
||||
-- Sharing data with a "C array" pointed by Tab.
|
||||
|
||||
returns Matrix
|
||||
raises RangeError;
|
||||
|
||||
|
||||
|
||||
Create(Other: Matrix)
|
||||
---Purpose: constructs a matrix for copy in initialization.
|
||||
-- An exception is raised if the matrixes have not the same dimensions.
|
||||
|
||||
returns Matrix
|
||||
raises DimensionError;
|
||||
--JR/Hp is private;
|
||||
|
||||
|
||||
SetLowerRow(me: in out; LowerRow: Integer)
|
||||
---Purpose: The new lower row of the matrix is set to <LowerRow>
|
||||
|
||||
is static protected;
|
||||
|
||||
|
||||
SetLowerCol(me: in out; LowerCol: Integer)
|
||||
---Purpose: The new lower column of the matrix is set to the column
|
||||
-- of range <LowerCol>.
|
||||
|
||||
is static protected;
|
||||
|
||||
|
||||
SetLower(me: in out; LowerRow, LowerCol: Integer)
|
||||
---Purpose: The new lower row of the matrix is set to <LowerRow>
|
||||
--- and the new lower column of the matrix is set to the column
|
||||
-- of range <LowerCol>.
|
||||
---C++: inline
|
||||
is static protected;
|
||||
|
||||
|
||||
Init(me : in out; InitialValue: Real)
|
||||
---Purpose:Initialize all the elements of a matrix to InitialValue.
|
||||
is static;
|
||||
|
||||
RowNumber(me)
|
||||
---Purpose: Returns the number of rows of this matrix.
|
||||
-- Note that for a matrix A you always have the following relations:
|
||||
-- - A.RowNumber() = A.UpperRow() - A.LowerRow() + 1
|
||||
-- - A.ColNumber() = A.UpperCol() - A.LowerCol() + 1
|
||||
-- - the length of a row of A is equal to the number of columns of A,
|
||||
-- - the length of a column of A is equal to the number of
|
||||
-- rows of A.returns the row range of a matrix.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
ColNumber(me)
|
||||
---Purpose: Returns the number of rows of this matrix.
|
||||
-- Note that for a matrix A you always have the following relations:
|
||||
-- - A.RowNumber() = A.UpperRow() - A.LowerRow() + 1
|
||||
-- - A.ColNumber() = A.UpperCol() - A.LowerCol() + 1
|
||||
-- - the length of a row of A is equal to the number of columns of A,
|
||||
-- - the length of a column of A is equal to the number of
|
||||
-- rows of A.returns the row range of a matrix.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
LowerRow(me)
|
||||
---Purpose: Returns the value of the Lower index of the row
|
||||
-- range of a matrix.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
UpperRow(me)
|
||||
---Purpose: Returns the Upper index of the row range
|
||||
-- of a matrix.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
LowerCol(me)
|
||||
---Purpose: Returns the value of the Lower index of the
|
||||
-- column range of a matrix.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
UpperCol(me)
|
||||
---Purpose: Returns the value of the upper index of the
|
||||
-- column range of a matrix.
|
||||
---C++: inline
|
||||
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
|
||||
Determinant(me)
|
||||
---Purpose: Computes the determinant of a matrix.
|
||||
-- An exception is raised if the matrix is not a square matrix.
|
||||
|
||||
returns Real
|
||||
raises NotSquare
|
||||
is static;
|
||||
|
||||
Transpose(me: in out)
|
||||
---Purpose: Transposes a given matrix.
|
||||
-- An exception is raised if the matrix is not a square matrix.
|
||||
|
||||
raises NotSquare from math
|
||||
is static;
|
||||
|
||||
|
||||
Invert(me: in out)
|
||||
---Purpose: Inverts a matrix using Gauss algorithm.
|
||||
-- Exception NotSquare is raised if the matrix is not square.
|
||||
-- Exception SingularMatrix is raised if the matrix is singular.
|
||||
|
||||
raises NotSquare from math,
|
||||
SingularMatrix from math
|
||||
is static;
|
||||
|
||||
|
||||
Multiply(me: in out; Right: Real)
|
||||
---Purpose: Sets this matrix to the product of the matrix Left, and the matrix Right.
|
||||
-- Example
|
||||
-- math_Matrix A (1, 3, 1, 3);
|
||||
-- math_Matrix B (1, 3, 1, 3);
|
||||
-- // A = ... , B = ...
|
||||
-- math_Matrix C (1, 3, 1, 3);
|
||||
-- C.Multiply(A, B);
|
||||
-- Exceptions
|
||||
-- Standard_DimensionError if matrices are of incompatible dimensions, i.e. if:
|
||||
-- - the number of columns of matrix Left, or the number of
|
||||
-- rows of matrix TLeft is not equal to the number of rows
|
||||
-- of matrix Right, or
|
||||
-- - the number of rows of matrix Left, or the number of
|
||||
-- columns of matrix TLeft is not equal to the number of
|
||||
-- rows of this matrix, or
|
||||
-- - the number of columns of matrix Right is not equal to
|
||||
-- the number of columns of this matrix.
|
||||
---C++: alias operator*=
|
||||
|
||||
is static;
|
||||
|
||||
Multiplied(me; Right: Real)
|
||||
---Purpose: multiplies all the elements of a matrix by the
|
||||
-- value <Right>.
|
||||
---C++: alias operator*
|
||||
|
||||
returns Matrix
|
||||
is static;
|
||||
|
||||
|
||||
TMultiplied(me; Right: Real)
|
||||
---Purpose: Sets this matrix to the product of the
|
||||
-- transposed matrix TLeft, and the matrix Right.
|
||||
-- Example
|
||||
-- math_Matrix A (1, 3, 1, 3);
|
||||
-- math_Matrix B (1, 3, 1, 3);
|
||||
-- // A = ... , B = ...
|
||||
-- math_Matrix C (1, 3, 1, 3);
|
||||
-- C.Multiply(A, B);
|
||||
-- Exceptions
|
||||
-- Standard_DimensionError if matrices are of incompatible dimensions, i.e. if:
|
||||
-- - the number of columns of matrix Left, or the number of
|
||||
-- rows of matrix TLeft is not equal to the number of rows
|
||||
-- of matrix Right, or
|
||||
-- - the number of rows of matrix Left, or the number of
|
||||
-- columns of matrix TLeft is not equal to the number of
|
||||
-- rows of this matrix, or
|
||||
-- - the number of columns of matrix Right is not equal to
|
||||
-- the number of columns of this matrix.
|
||||
---C++: alias "friend math_Matrix operator *(const Standard_Real Left,const math_Matrix& Right);"
|
||||
returns Matrix
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Divide(me: in out; Right: Real)
|
||||
---Purpose: divides all the elements of a matrix by the value <Right>.
|
||||
-- An exception is raised if <Right> = 0.
|
||||
---C++: alias operator/=
|
||||
|
||||
raises DivideByZero
|
||||
is static;
|
||||
|
||||
|
||||
Divided(me; Right: Real)
|
||||
---Purpose: divides all the elements of a matrix by the value <Right>.
|
||||
-- An exception is raised if <Right> = 0.
|
||||
---C++: alias operator/
|
||||
|
||||
returns Matrix
|
||||
raises DivideByZero
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Add(me: in out; Right: Matrix)
|
||||
---Purpose: adds the matrix <Right> to a matrix.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
-- Warning
|
||||
-- In order to save time when copying matrices, it is
|
||||
-- preferable to use operator += or the function Add
|
||||
-- whenever possible.
|
||||
---C++: alias operator+=
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Added(me; Right: Matrix)
|
||||
---Purpose: adds the matrix <Right> to a matrix.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
---C++: alias operator+
|
||||
returns Matrix
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Add(me: in out; Left, Right: Matrix)
|
||||
---Purpose: sets a matrix to the addition of <Left> and <Right>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
Subtract(me: in out; Right: Matrix)
|
||||
---Purpose: Subtracts the matrix <Right> from <me>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
-- Warning
|
||||
-- In order to avoid time-consuming copying of matrices, it
|
||||
-- is preferable to use operator -= or the function
|
||||
-- Subtract whenever possible.
|
||||
---C++: alias operator-=
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Subtracted(me; Right: Matrix)
|
||||
---Purpose: Returns the result of the subtraction of <Right> from <me>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
---C++: alias operator-
|
||||
|
||||
returns Matrix
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Set(me: in out; I1, I2, J1, J2: Integer; M: Matrix)
|
||||
---Purpose: Sets the values of this matrix,
|
||||
-- - from index I1 to index I2 on the row dimension, and
|
||||
-- - from index J1 to index J2 on the column dimension,
|
||||
-- to those of matrix M.
|
||||
-- Exceptions
|
||||
-- Standard_DimensionError if:
|
||||
-- - I1 is less than the index of the lower row bound of this matrix, or
|
||||
-- - I2 is greater than the index of the upper row bound of this matrix, or
|
||||
-- - J1 is less than the index of the lower column bound of this matrix, or
|
||||
-- - J2 is greater than the index of the upper column bound of this matrix, or
|
||||
-- - I2 - I1 + 1 is not equal to the number of rows of matrix M, or
|
||||
-- - J2 - J1 + 1 is not equal to the number of columns of matrix M.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
SetRow(me: in out; Row: Integer; V: Vector)
|
||||
---Purpose: Sets the row of index Row of a matrix to the vector <V>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
-- An exception is raises if <Row> is inferior to the lower
|
||||
-- row of the matrix or <Row> is superior to the upper row.
|
||||
|
||||
raises RangeError, DimensionError
|
||||
is static;
|
||||
|
||||
SetCol(me: in out; Col: Integer; V: Vector)
|
||||
---Purpose: Sets the column of index Col of a matrix to the vector <V>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
-- An exception is raises if <Col> is inferior to the lower
|
||||
-- column of the matrix or <Col> is superior to the upper
|
||||
-- column.
|
||||
|
||||
raises RangeError, DimensionError
|
||||
is static;
|
||||
|
||||
SetDiag(me: in out; Value: Real)
|
||||
---Purpose: Sets the diagonal of a matrix to the value <Value>.
|
||||
-- An exception is raised if the matrix is not square.
|
||||
|
||||
raises NotSquare
|
||||
is static;
|
||||
|
||||
Row(me; Row: Integer)
|
||||
---Purpose: Returns the row of index Row of a matrix.
|
||||
|
||||
returns Vector
|
||||
is static;
|
||||
|
||||
Col(me; Col: Integer)
|
||||
---Purpose: Returns the column of index <Col> of a matrix.
|
||||
|
||||
returns Vector
|
||||
is static;
|
||||
|
||||
|
||||
SwapRow(me: in out; Row1, Row2: Integer)
|
||||
---Purpose: Swaps the rows of index Row1 and Row2.
|
||||
-- An exception is raised if <Row1> or <Row2> is out of range.
|
||||
|
||||
raises RangeError
|
||||
is static;
|
||||
|
||||
|
||||
SwapCol(me: in out; Col1, Col2: Integer)
|
||||
---Purpose: Swaps the columns of index <Col1> and <Col2>.
|
||||
-- An exception is raised if <Col1> or <Col2> is out of range.
|
||||
|
||||
raises RangeError
|
||||
is static;
|
||||
|
||||
|
||||
Transposed(me)
|
||||
---Purpose: Teturns the transposed of a matrix.
|
||||
-- An exception is raised if the matrix is not a square matrix.
|
||||
|
||||
returns Matrix
|
||||
raises NotSquare
|
||||
is static;
|
||||
|
||||
|
||||
Inverse(me)
|
||||
---Purpose: Returns the inverse of a matrix.
|
||||
-- Exception NotSquare is raised if the matrix is not square.
|
||||
-- Exception SingularMatrix is raised if the matrix is singular.
|
||||
|
||||
returns Matrix
|
||||
raises NotSquare, SingularMatrix
|
||||
is static;
|
||||
|
||||
|
||||
TMultiply(me; Right: Matrix)
|
||||
---Purpose: Returns the product of the transpose of a matrix with
|
||||
-- the matrix <Right>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
|
||||
returns Matrix
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Multiply(me: in out; Left, Right: Vector)
|
||||
---Purpose: Computes a matrix as the product of 2 vectors.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
-- <me> = <Left> * <Right>.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Multiply(me: in out; Left, Right: Matrix)
|
||||
---Purpose: Computes a matrix as the product of 2 matrixes.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
TMultiply(me: in out; TLeft, Right: Matrix)
|
||||
---Purpose: Computes a matrix to the product of the transpose of
|
||||
-- the matrix <TLeft> with the matrix <Right>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Subtract(me: in out; Left, Right: Matrix)
|
||||
---Purpose: Sets a matrix to the Subtraction of the matrix <Right>
|
||||
-- from the matrix <Left>.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Value(me; Row, Col: Integer)
|
||||
---Purpose: Accesses (in read or write mode) the value of index <Row>
|
||||
-- and <Col> of a matrix.
|
||||
-- An exception is raised if <Row> and <Col> are not
|
||||
-- in the correct range.
|
||||
---C++: alias operator()
|
||||
---C++: return &
|
||||
---C++: inline
|
||||
|
||||
returns Real
|
||||
raises RangeError
|
||||
is static;
|
||||
|
||||
|
||||
Initialized(me: in out; Other: Matrix)
|
||||
---Purpose: Matrixes are copied through assignement.
|
||||
-- An exception is raised if the dimensions are differents.
|
||||
---C++: alias operator=
|
||||
---C++: return &
|
||||
|
||||
returns Matrix
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Multiply(me: in out; Right: Matrix)
|
||||
---Purpose: Returns the product of 2 matrices.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
---C++: alias operator*=
|
||||
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Multiplied(me; Right: Matrix)
|
||||
---Purpose: Returns the product of 2 matrices.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
---C++: alias operator*
|
||||
|
||||
returns Matrix
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
|
||||
Multiplied(me; Right: Vector)
|
||||
---Purpose: Returns the product of a matrix by a vector.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
---C++: alias operator*
|
||||
|
||||
returns Vector
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
Opposite(me : in out)
|
||||
---Purpose: Returns the opposite of a matrix.
|
||||
-- An exception is raised if the dimensions are different.
|
||||
---C++: alias operator-
|
||||
|
||||
returns Matrix
|
||||
raises DimensionError from Standard
|
||||
is static;
|
||||
|
||||
|
||||
Dump(me; o: in out OStream)
|
||||
---Purpose: Prints information on the current state of the object.
|
||||
-- Is used to redefine the operator <<.
|
||||
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
LowerRowIndex: Integer;
|
||||
UpperRowIndex: Integer;
|
||||
LowerColIndex: Integer;
|
||||
UpperColIndex: Integer;
|
||||
Array: DoubleTab;
|
||||
|
||||
friends
|
||||
class Vector from math
|
||||
|
||||
end Matrix;
|
||||
|
@@ -12,16 +12,15 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_Matrix.ixx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
#include <math_Gauss.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_NotSquare.hxx>
|
||||
#include <math_SingularMatrix.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_DimensionError.hxx>
|
||||
#include <Standard_DivideByZero.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <math_SingularMatrix.hxx>
|
||||
#include <math_NotSquare.hxx>
|
||||
#include <math_Gauss.hxx>
|
||||
|
||||
|
||||
void math_Matrix::SetLowerRow(const Standard_Integer LowerRow) {
|
||||
|
||||
|
436
src/math/math_Matrix.hxx
Normal file
436
src/math/math_Matrix.hxx
Normal file
@@ -0,0 +1,436 @@
|
||||
// Created on: 1991-05-07
|
||||
// Created by: Laurent PAINNOT
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_Matrix_HeaderFile
|
||||
#define _math_Matrix_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_DoubleTab.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Address.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_DimensionError;
|
||||
class Standard_RangeError;
|
||||
class Standard_DivideByZero;
|
||||
class math_NotSquare;
|
||||
class math_SingularMatrix;
|
||||
class math_Vector;
|
||||
|
||||
|
||||
//! This class implements the real matrix abstract data type.
|
||||
//! Matrixes can have an arbitrary range which must be defined
|
||||
//! at the declaration and cannot be changed after this declaration
|
||||
//! math_Matrix(-3,5,2,4); //a vector with range [-3..5, 2..4]
|
||||
//! Matrix values may be initialized and
|
||||
//! retrieved using indexes which must lie within the range
|
||||
//! of definition of the matrix.
|
||||
//! Matrix objects follow "value semantics", that is, they
|
||||
//! cannot be shared and are copied through assignment
|
||||
//! Matrices are copied through assignement:
|
||||
//! math_Matrix M2(1, 9, 1, 3);
|
||||
//! ...
|
||||
//! M2 = M1;
|
||||
//! M1(1) = 2.0;//the matrix M2 will not be modified.
|
||||
//!
|
||||
//! The exception RangeError is raised when trying to access
|
||||
//! outside the range of a matrix :
|
||||
//! M1(11, 1)=0.0// --> will raise RangeError.
|
||||
//!
|
||||
//! The exception DimensionError is raised when the dimensions of
|
||||
//! two matrices or vectors are not compatible.
|
||||
//! math_Matrix M3(1, 2, 1, 2);
|
||||
//! M3 = M1; // will raise DimensionError
|
||||
//! M1.Add(M3) // --> will raise DimensionError.
|
||||
//! A Matrix can be constructed with a a pointer to "c array".
|
||||
//! It allows to carry the bounds inside the matrix.
|
||||
//! Exemple :
|
||||
//! Standard_Real tab1[10][20];
|
||||
//! Standard_Real tab2[200];
|
||||
//!
|
||||
//! math_Matrix A (tab1[0][0], 1, 10, 1, 20);
|
||||
//! math_Matrix B (tab2[0], 1, 10, 1, 20);
|
||||
class math_Matrix
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Constructs a non-initialized matrix of range [LowerRow..UpperRow,
|
||||
//! LowerCol..UpperCol]
|
||||
//! For the constructed matrix:
|
||||
//! - LowerRow and UpperRow are the indexes of the
|
||||
//! lower and upper bounds of a row, and
|
||||
//! - LowerCol and UpperCol are the indexes of the
|
||||
//! lower and upper bounds of a column.
|
||||
Standard_EXPORT math_Matrix(const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol);
|
||||
|
||||
//! constructs a non-initialized matrix of range [LowerRow..UpperRow,
|
||||
//! LowerCol..UpperCol]
|
||||
//! whose values are all initialized with the value InitialValue.
|
||||
Standard_EXPORT math_Matrix(const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol, const Standard_Real InitialValue);
|
||||
|
||||
//! constructs a matrix of range [LowerRow..UpperRow,
|
||||
//! LowerCol..UpperCol]
|
||||
//! Sharing data with a "C array" pointed by Tab.
|
||||
Standard_EXPORT math_Matrix(const Standard_Address Tab, const Standard_Integer LowerRow, const Standard_Integer UpperRow, const Standard_Integer LowerCol, const Standard_Integer UpperCol);
|
||||
|
||||
//! constructs a matrix for copy in initialization.
|
||||
//! An exception is raised if the matrixes have not the same dimensions.
|
||||
Standard_EXPORT math_Matrix(const math_Matrix& Other);
|
||||
|
||||
//! Initialize all the elements of a matrix to InitialValue.
|
||||
Standard_EXPORT void Init (const Standard_Real InitialValue);
|
||||
|
||||
//! Returns the number of rows of this matrix.
|
||||
//! Note that for a matrix A you always have the following relations:
|
||||
//! - A.RowNumber() = A.UpperRow() - A.LowerRow() + 1
|
||||
//! - A.ColNumber() = A.UpperCol() - A.LowerCol() + 1
|
||||
//! - the length of a row of A is equal to the number of columns of A,
|
||||
//! - the length of a column of A is equal to the number of
|
||||
//! rows of A.returns the row range of a matrix.
|
||||
Standard_Integer RowNumber() const;
|
||||
|
||||
//! Returns the number of rows of this matrix.
|
||||
//! Note that for a matrix A you always have the following relations:
|
||||
//! - A.RowNumber() = A.UpperRow() - A.LowerRow() + 1
|
||||
//! - A.ColNumber() = A.UpperCol() - A.LowerCol() + 1
|
||||
//! - the length of a row of A is equal to the number of columns of A,
|
||||
//! - the length of a column of A is equal to the number of
|
||||
//! rows of A.returns the row range of a matrix.
|
||||
Standard_Integer ColNumber() const;
|
||||
|
||||
//! Returns the value of the Lower index of the row
|
||||
//! range of a matrix.
|
||||
Standard_Integer LowerRow() const;
|
||||
|
||||
//! Returns the Upper index of the row range
|
||||
//! of a matrix.
|
||||
Standard_Integer UpperRow() const;
|
||||
|
||||
//! Returns the value of the Lower index of the
|
||||
//! column range of a matrix.
|
||||
Standard_Integer LowerCol() const;
|
||||
|
||||
//! Returns the value of the upper index of the
|
||||
//! column range of a matrix.
|
||||
Standard_Integer UpperCol() const;
|
||||
|
||||
//! Computes the determinant of a matrix.
|
||||
//! An exception is raised if the matrix is not a square matrix.
|
||||
Standard_EXPORT Standard_Real Determinant() const;
|
||||
|
||||
//! Transposes a given matrix.
|
||||
//! An exception is raised if the matrix is not a square matrix.
|
||||
Standard_EXPORT void Transpose();
|
||||
|
||||
//! Inverts a matrix using Gauss algorithm.
|
||||
//! Exception NotSquare is raised if the matrix is not square.
|
||||
//! Exception SingularMatrix is raised if the matrix is singular.
|
||||
Standard_EXPORT void Invert();
|
||||
|
||||
//! Sets this matrix to the product of the matrix Left, and the matrix Right.
|
||||
//! Example
|
||||
//! math_Matrix A (1, 3, 1, 3);
|
||||
//! math_Matrix B (1, 3, 1, 3);
|
||||
//! // A = ... , B = ...
|
||||
//! math_Matrix C (1, 3, 1, 3);
|
||||
//! C.Multiply(A, B);
|
||||
//! Exceptions
|
||||
//! Standard_DimensionError if matrices are of incompatible dimensions, i.e. if:
|
||||
//! - the number of columns of matrix Left, or the number of
|
||||
//! rows of matrix TLeft is not equal to the number of rows
|
||||
//! of matrix Right, or
|
||||
//! - the number of rows of matrix Left, or the number of
|
||||
//! columns of matrix TLeft is not equal to the number of
|
||||
//! rows of this matrix, or
|
||||
//! - the number of columns of matrix Right is not equal to
|
||||
//! the number of columns of this matrix.
|
||||
Standard_EXPORT void Multiply (const Standard_Real Right);
|
||||
void operator*= (const Standard_Real Right)
|
||||
{
|
||||
Multiply(Right);
|
||||
}
|
||||
|
||||
//! multiplies all the elements of a matrix by the
|
||||
//! value <Right>.
|
||||
Standard_EXPORT math_Matrix Multiplied (const Standard_Real Right) const;
|
||||
math_Matrix operator* (const Standard_Real Right) const
|
||||
{
|
||||
return Multiplied(Right);
|
||||
}
|
||||
|
||||
//! Sets this matrix to the product of the
|
||||
//! transposed matrix TLeft, and the matrix Right.
|
||||
//! Example
|
||||
//! math_Matrix A (1, 3, 1, 3);
|
||||
//! math_Matrix B (1, 3, 1, 3);
|
||||
//! // A = ... , B = ...
|
||||
//! math_Matrix C (1, 3, 1, 3);
|
||||
//! C.Multiply(A, B);
|
||||
//! Exceptions
|
||||
//! Standard_DimensionError if matrices are of incompatible dimensions, i.e. if:
|
||||
//! - the number of columns of matrix Left, or the number of
|
||||
//! rows of matrix TLeft is not equal to the number of rows
|
||||
//! of matrix Right, or
|
||||
//! - the number of rows of matrix Left, or the number of
|
||||
//! columns of matrix TLeft is not equal to the number of
|
||||
//! rows of this matrix, or
|
||||
//! - the number of columns of matrix Right is not equal to
|
||||
//! the number of columns of this matrix.
|
||||
Standard_EXPORT math_Matrix TMultiplied (const Standard_Real Right) const;
|
||||
friend math_Matrix operator *(const Standard_Real Left,const math_Matrix& Right);
|
||||
|
||||
//! divides all the elements of a matrix by the value <Right>.
|
||||
//! An exception is raised if <Right> = 0.
|
||||
Standard_EXPORT void Divide (const Standard_Real Right);
|
||||
void operator/= (const Standard_Real Right)
|
||||
{
|
||||
Divide(Right);
|
||||
}
|
||||
|
||||
//! divides all the elements of a matrix by the value <Right>.
|
||||
//! An exception is raised if <Right> = 0.
|
||||
Standard_EXPORT math_Matrix Divided (const Standard_Real Right) const;
|
||||
math_Matrix operator/ (const Standard_Real Right) const
|
||||
{
|
||||
return Divided(Right);
|
||||
}
|
||||
|
||||
//! adds the matrix <Right> to a matrix.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
//! Warning
|
||||
//! In order to save time when copying matrices, it is
|
||||
//! preferable to use operator += or the function Add
|
||||
//! whenever possible.
|
||||
Standard_EXPORT void Add (const math_Matrix& Right);
|
||||
void operator+= (const math_Matrix& Right)
|
||||
{
|
||||
Add(Right);
|
||||
}
|
||||
|
||||
//! adds the matrix <Right> to a matrix.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT math_Matrix Added (const math_Matrix& Right) const;
|
||||
math_Matrix operator+ (const math_Matrix& Right) const
|
||||
{
|
||||
return Added(Right);
|
||||
}
|
||||
|
||||
//! sets a matrix to the addition of <Left> and <Right>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT void Add (const math_Matrix& Left, const math_Matrix& Right);
|
||||
|
||||
//! Subtracts the matrix <Right> from <me>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
//! Warning
|
||||
//! In order to avoid time-consuming copying of matrices, it
|
||||
//! is preferable to use operator -= or the function
|
||||
//! Subtract whenever possible.
|
||||
Standard_EXPORT void Subtract (const math_Matrix& Right);
|
||||
void operator-= (const math_Matrix& Right)
|
||||
{
|
||||
Subtract(Right);
|
||||
}
|
||||
|
||||
//! Returns the result of the subtraction of <Right> from <me>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT math_Matrix Subtracted (const math_Matrix& Right) const;
|
||||
math_Matrix operator- (const math_Matrix& Right) const
|
||||
{
|
||||
return Subtracted(Right);
|
||||
}
|
||||
|
||||
//! Sets the values of this matrix,
|
||||
//! - from index I1 to index I2 on the row dimension, and
|
||||
//! - from index J1 to index J2 on the column dimension,
|
||||
//! to those of matrix M.
|
||||
//! Exceptions
|
||||
//! Standard_DimensionError if:
|
||||
//! - I1 is less than the index of the lower row bound of this matrix, or
|
||||
//! - I2 is greater than the index of the upper row bound of this matrix, or
|
||||
//! - J1 is less than the index of the lower column bound of this matrix, or
|
||||
//! - J2 is greater than the index of the upper column bound of this matrix, or
|
||||
//! - I2 - I1 + 1 is not equal to the number of rows of matrix M, or
|
||||
//! - J2 - J1 + 1 is not equal to the number of columns of matrix M.
|
||||
Standard_EXPORT void Set (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer J1, const Standard_Integer J2, const math_Matrix& M);
|
||||
|
||||
//! Sets the row of index Row of a matrix to the vector <V>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
//! An exception is raises if <Row> is inferior to the lower
|
||||
//! row of the matrix or <Row> is superior to the upper row.
|
||||
Standard_EXPORT void SetRow (const Standard_Integer Row, const math_Vector& V);
|
||||
|
||||
//! Sets the column of index Col of a matrix to the vector <V>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
//! An exception is raises if <Col> is inferior to the lower
|
||||
//! column of the matrix or <Col> is superior to the upper
|
||||
//! column.
|
||||
Standard_EXPORT void SetCol (const Standard_Integer Col, const math_Vector& V);
|
||||
|
||||
//! Sets the diagonal of a matrix to the value <Value>.
|
||||
//! An exception is raised if the matrix is not square.
|
||||
Standard_EXPORT void SetDiag (const Standard_Real Value);
|
||||
|
||||
//! Returns the row of index Row of a matrix.
|
||||
Standard_EXPORT math_Vector Row (const Standard_Integer Row) const;
|
||||
|
||||
//! Returns the column of index <Col> of a matrix.
|
||||
Standard_EXPORT math_Vector Col (const Standard_Integer Col) const;
|
||||
|
||||
//! Swaps the rows of index Row1 and Row2.
|
||||
//! An exception is raised if <Row1> or <Row2> is out of range.
|
||||
Standard_EXPORT void SwapRow (const Standard_Integer Row1, const Standard_Integer Row2);
|
||||
|
||||
//! Swaps the columns of index <Col1> and <Col2>.
|
||||
//! An exception is raised if <Col1> or <Col2> is out of range.
|
||||
Standard_EXPORT void SwapCol (const Standard_Integer Col1, const Standard_Integer Col2);
|
||||
|
||||
//! Teturns the transposed of a matrix.
|
||||
//! An exception is raised if the matrix is not a square matrix.
|
||||
Standard_EXPORT math_Matrix Transposed() const;
|
||||
|
||||
//! Returns the inverse of a matrix.
|
||||
//! Exception NotSquare is raised if the matrix is not square.
|
||||
//! Exception SingularMatrix is raised if the matrix is singular.
|
||||
Standard_EXPORT math_Matrix Inverse() const;
|
||||
|
||||
//! Returns the product of the transpose of a matrix with
|
||||
//! the matrix <Right>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT math_Matrix TMultiply (const math_Matrix& Right) const;
|
||||
|
||||
//! Computes a matrix as the product of 2 vectors.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
//! <me> = <Left> * <Right>.
|
||||
Standard_EXPORT void Multiply (const math_Vector& Left, const math_Vector& Right);
|
||||
|
||||
//! Computes a matrix as the product of 2 matrixes.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT void Multiply (const math_Matrix& Left, const math_Matrix& Right);
|
||||
|
||||
//! Computes a matrix to the product of the transpose of
|
||||
//! the matrix <TLeft> with the matrix <Right>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT void TMultiply (const math_Matrix& TLeft, const math_Matrix& Right);
|
||||
|
||||
//! Sets a matrix to the Subtraction of the matrix <Right>
|
||||
//! from the matrix <Left>.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT void Subtract (const math_Matrix& Left, const math_Matrix& Right);
|
||||
|
||||
//! Accesses (in read or write mode) the value of index <Row>
|
||||
//! and <Col> of a matrix.
|
||||
//! An exception is raised if <Row> and <Col> are not
|
||||
//! in the correct range.
|
||||
Standard_Real& Value (const Standard_Integer Row, const Standard_Integer Col) const;
|
||||
Standard_Real& operator() (const Standard_Integer Row, const Standard_Integer Col) const
|
||||
{
|
||||
return Value(Row,Col);
|
||||
}
|
||||
|
||||
//! Matrixes are copied through assignement.
|
||||
//! An exception is raised if the dimensions are differents.
|
||||
Standard_EXPORT math_Matrix& Initialized (const math_Matrix& Other);
|
||||
math_Matrix& operator= (const math_Matrix& Other)
|
||||
{
|
||||
return Initialized(Other);
|
||||
}
|
||||
|
||||
//! Returns the product of 2 matrices.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT void Multiply (const math_Matrix& Right);
|
||||
void operator*= (const math_Matrix& Right)
|
||||
{
|
||||
Multiply(Right);
|
||||
}
|
||||
|
||||
//! Returns the product of 2 matrices.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT math_Matrix Multiplied (const math_Matrix& Right) const;
|
||||
math_Matrix operator* (const math_Matrix& Right) const
|
||||
{
|
||||
return Multiplied(Right);
|
||||
}
|
||||
|
||||
//! Returns the product of a matrix by a vector.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT math_Vector Multiplied (const math_Vector& Right) const;
|
||||
math_Vector operator* (const math_Vector& Right) const
|
||||
{
|
||||
return Multiplied(Right);
|
||||
}
|
||||
|
||||
//! Returns the opposite of a matrix.
|
||||
//! An exception is raised if the dimensions are different.
|
||||
Standard_EXPORT math_Matrix Opposite();
|
||||
math_Matrix operator-()
|
||||
{
|
||||
return Opposite();
|
||||
}
|
||||
|
||||
//! Prints information on the current state of the object.
|
||||
//! Is used to redefine the operator <<.
|
||||
Standard_EXPORT void Dump (Standard_OStream& o) const;
|
||||
|
||||
|
||||
friend class math_Vector;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//! The new lower row of the matrix is set to <LowerRow>
|
||||
Standard_EXPORT void SetLowerRow (const Standard_Integer LowerRow);
|
||||
|
||||
//! The new lower column of the matrix is set to the column
|
||||
//! of range <LowerCol>.
|
||||
Standard_EXPORT void SetLowerCol (const Standard_Integer LowerCol);
|
||||
|
||||
//! The new lower row of the matrix is set to <LowerRow>
|
||||
//! and the new lower column of the matrix is set to the column
|
||||
//! of range <LowerCol>.
|
||||
void SetLower (const Standard_Integer LowerRow, const Standard_Integer LowerCol);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Integer LowerRowIndex;
|
||||
Standard_Integer UpperRowIndex;
|
||||
Standard_Integer LowerColIndex;
|
||||
Standard_Integer UpperColIndex;
|
||||
math_DoubleTab Array;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <math_Matrix.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_Matrix_HeaderFile
|
@@ -1,62 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent Painnot
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class MultipleVarFunction from math
|
||||
---Purpose:
|
||||
-- Describes the virtual functions associated with a multiple variable function.
|
||||
uses Vector from math
|
||||
|
||||
is
|
||||
NbVariables(me)
|
||||
---Purpose:
|
||||
-- Returns the number of variables of the function
|
||||
|
||||
returns Integer
|
||||
is deferred;
|
||||
|
||||
|
||||
Value(me: in out; X: Vector; F: out Real)
|
||||
---Purpose: Computes the values of the Functions <F> for the
|
||||
-- variable <X>.
|
||||
-- returns True if the computation was done successfully,
|
||||
-- otherwise false.
|
||||
|
||||
returns Boolean
|
||||
is deferred;
|
||||
|
||||
|
||||
GetStateNumber(me: in out)
|
||||
---Purpose: return the state of the function corresponding to the latestt
|
||||
-- call of any methods associated to the function. This
|
||||
-- function is called by each of the algorithms described
|
||||
-- later which define the function Integer
|
||||
-- Algorithm::StateNumber(). The algorithm has the
|
||||
-- responsibility to call this function when it has found
|
||||
-- a solution (i.e. a root or a minimum) and has to maintain
|
||||
-- the association between the solution found and this
|
||||
-- StateNumber.
|
||||
-- Byu default, this method returns 0 (which means for the
|
||||
-- algorithm: no state has been saved). It is the
|
||||
-- responsibility of the programmer to decide if he needs
|
||||
-- to save the current state of the function and to return
|
||||
-- an Integer that allows retrieval of the state.
|
||||
|
||||
returns Integer
|
||||
is virtual;
|
||||
|
||||
---C++: alias " Standard_EXPORT virtual ~math_MultipleVarFunction();"
|
||||
|
||||
end MultipleVarFunction;
|
@@ -12,8 +12,9 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <math_MultipleVarFunction.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <math_MultipleVarFunction.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ~math_MultipleVarFunction
|
||||
|
89
src/math/math_MultipleVarFunction.hxx
Normal file
89
src/math/math_MultipleVarFunction.hxx
Normal file
@@ -0,0 +1,89 @@
|
||||
// Created on: 1991-05-13
|
||||
// Created by: Laurent Painnot
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _math_MultipleVarFunction_HeaderFile
|
||||
#define _math_MultipleVarFunction_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
|
||||
|
||||
|
||||
//! Describes the virtual functions associated with a multiple variable function.
|
||||
class math_MultipleVarFunction
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
|
||||
//! Returns the number of variables of the function
|
||||
Standard_EXPORT virtual Standard_Integer NbVariables() const = 0;
|
||||
|
||||
//! Computes the values of the Functions <F> for the
|
||||
//! variable <X>.
|
||||
//! returns True if the computation was done successfully,
|
||||
//! otherwise false.
|
||||
Standard_EXPORT virtual Standard_Boolean Value (const math_Vector& X, Standard_Real& F) = 0;
|
||||
|
||||
//! return the state of the function corresponding to the latestt
|
||||
//! call of any methods associated to the function. This
|
||||
//! function is called by each of the algorithms described
|
||||
//! later which define the function Integer
|
||||
//! Algorithm::StateNumber(). The algorithm has the
|
||||
//! responsibility to call this function when it has found
|
||||
//! a solution (i.e. a root or a minimum) and has to maintain
|
||||
//! the association between the solution found and this
|
||||
//! StateNumber.
|
||||
//! Byu default, this method returns 0 (which means for the
|
||||
//! algorithm: no state has been saved). It is the
|
||||
//! responsibility of the programmer to decide if he needs
|
||||
//! to save the current state of the function and to return
|
||||
//! an Integer that allows retrieval of the state.
|
||||
Standard_EXPORT virtual Standard_Integer GetStateNumber();
|
||||
Standard_EXPORT virtual ~math_MultipleVarFunction();
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _math_MultipleVarFunction_HeaderFile
|
@@ -1,56 +0,0 @@
|
||||
-- Created on: 1991-05-13
|
||||
-- Created by: Laurent PAINNOT
|
||||
-- Copyright (c) 1991-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class MultipleVarFunctionWithGradient from math
|
||||
|
||||
inherits MultipleVarFunction
|
||||
---Purpose:
|
||||
-- The abstract class MultipleVarFunctionWithGradient
|
||||
-- describes the virtual functions associated with a multiple variable function.
|
||||
uses Vector from math
|
||||
|
||||
is
|
||||
NbVariables(me)
|
||||
---Purpose: Returns the number of variables of the function.
|
||||
|
||||
returns Integer is deferred;
|
||||
|
||||
|
||||
Value(me: in out; X: Vector; F: out Real)
|
||||
---Purpose: Computes the values of the Functions <F> for the variable <X>.
|
||||
-- Returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
|
||||
Gradient(me: in out; X: Vector; G: out Vector)
|
||||
---Purpose: Computes the gradient <G> of the functions for the variable <X>.
|
||||
-- Returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
|
||||
Values(me: in out; X: Vector; F: out Real; G: out Vector)
|
||||
---Purpose: computes the value <F> and the gradient <G> of the
|
||||
-- functions for the variable <X>.
|
||||
-- Returns True if the computation was done successfully,
|
||||
-- False otherwise.
|
||||
|
||||
returns Boolean is deferred;
|
||||
|
||||
end MultipleVarFunctionWithGradient;
|
@@ -12,4 +12,5 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <math_MultipleVarFunctionWithGradient.ixx>
|
||||
|
||||
#include <math_MultipleVarFunctionWithGradient.hxx>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user