Foundation Classes - Remove PLib_DoubleJacobiPolynomial implementation and tests (#781)

Delete PLib_DoubleJacobiPolynomial sources (cxx/hxx/lxx), remove associated Google Test (PLib_DoubleJacobiPolynomial_Test.cxx)
and update FILES.cmake entries in TKMath/PLib and TKMath/GTests to stop building the removed files.
This commit is contained in:
Pasukhin Dmitry
2025-10-30 17:23:13 +00:00
committed by GitHub
parent f4c2224d86
commit bc1b021e86
6 changed files with 0 additions and 894 deletions

View File

@@ -38,5 +38,4 @@ set(OCCT_TKMath_GTests_FILES
PLib_Test.cxx
PLib_JacobiPolynomial_Test.cxx
PLib_HermitJacobi_Test.cxx
PLib_DoubleJacobiPolynomial_Test.cxx
)

View File

@@ -1,402 +0,0 @@
// Copyright (c) 2025 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.
#include <PLib_DoubleJacobiPolynomial.hxx>
#include <PLib_JacobiPolynomial.hxx>
#include <gtest/gtest.h>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <GeomAbs_Shape.hxx>
#include <Precision.hxx>
// Test fixture for PLib_DoubleJacobiPolynomial tests
class PLibDoubleJacobiPolynomialTest : public ::testing::Test
{
protected:
void SetUp() override
{
// Create Jacobi polynomials for testing
myJacobiU = new PLib_JacobiPolynomial(10, GeomAbs_C0);
myJacobiV = new PLib_JacobiPolynomial(8, GeomAbs_C1);
}
void TearDown() override
{
myJacobiU.Nullify();
myJacobiV.Nullify();
}
Handle(PLib_JacobiPolynomial) myJacobiU;
Handle(PLib_JacobiPolynomial) myJacobiV;
// Helper to create test coefficients
void createTestCoefficients(TColStd_Array1OfReal& theCoeffs,
Standard_Integer theDimension,
Standard_Integer theDegreeU,
Standard_Integer theDegreeV)
{
Standard_Integer anIndex = theCoeffs.Lower(); // Start from array lower bound
for (Standard_Integer j = 0; j <= theDegreeV; j++)
{
for (Standard_Integer i = 0; i <= theDegreeU; i++)
{
for (Standard_Integer d = 1; d <= theDimension; d++)
{
theCoeffs(anIndex) = Sin(anIndex * 0.1 + i * 0.2 + j * 0.3);
anIndex++;
}
}
}
}
};
// Test default constructor
TEST_F(PLibDoubleJacobiPolynomialTest, DefaultConstructor)
{
PLib_DoubleJacobiPolynomial aDoubleJac;
// After default construction, accessors should return null handles
EXPECT_TRUE(aDoubleJac.U().IsNull()) << "U polynomial should be null after default construction";
EXPECT_TRUE(aDoubleJac.V().IsNull()) << "V polynomial should be null after default construction";
EXPECT_TRUE(aDoubleJac.TabMaxU().IsNull()) << "TabMaxU should be null after default construction";
EXPECT_TRUE(aDoubleJac.TabMaxV().IsNull()) << "TabMaxV should be null after default construction";
}
// Test parameterized constructor
TEST_F(PLibDoubleJacobiPolynomialTest, ParameterizedConstructor)
{
ASSERT_FALSE(myJacobiU.IsNull()) << "JacobiU should not be null";
ASSERT_FALSE(myJacobiV.IsNull()) << "JacobiV should not be null";
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
// After construction with parameters, accessors should return valid handles
EXPECT_FALSE(aDoubleJac.U().IsNull()) << "U polynomial should not be null";
EXPECT_FALSE(aDoubleJac.V().IsNull()) << "V polynomial should not be null";
EXPECT_FALSE(aDoubleJac.TabMaxU().IsNull()) << "TabMaxU should not be null";
EXPECT_FALSE(aDoubleJac.TabMaxV().IsNull()) << "TabMaxV should not be null";
// Test that the returned handles are correct
EXPECT_EQ(aDoubleJac.U().get(), myJacobiU.get()) << "U polynomial handle should match";
EXPECT_EQ(aDoubleJac.V().get(), myJacobiV.get()) << "V polynomial handle should match";
}
// Test MaxErrorU calculation
TEST_F(PLibDoubleJacobiPolynomialTest, MaxErrorU)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
const Standard_Integer aDimension = 2;
const Standard_Integer aDegreeU = 6;
const Standard_Integer aDegreeV = 5;
const Standard_Integer aDJacCoeff = (aDegreeU + 1) * aDimension;
// JacCoeff array must be sized based on WorkDegrees
const Standard_Integer aWorkDegreeU = myJacobiU->WorkDegree();
const Standard_Integer aWorkDegreeV = myJacobiV->WorkDegree();
const Standard_Integer aCoeffCount = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
TColStd_Array1OfReal aJacCoeff(0, aCoeffCount - 1);
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = Sin(i * 0.1);
}
EXPECT_NO_THROW({
Standard_Real aMaxErrU =
aDoubleJac.MaxErrorU(aDimension, aDegreeU, aDegreeV, aDJacCoeff, aJacCoeff);
EXPECT_GE(aMaxErrU, 0.0) << "MaxErrorU should be non-negative";
EXPECT_FALSE(Precision::IsInfinite(aMaxErrU)) << "MaxErrorU should be finite";
}) << "MaxErrorU calculation failed";
}
// Test MaxErrorV calculation
TEST_F(PLibDoubleJacobiPolynomialTest, MaxErrorV)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
const Standard_Integer aDimension = 2;
const Standard_Integer aDegreeU = 6;
const Standard_Integer aDegreeV = 5;
const Standard_Integer aDJacCoeff = (aDegreeU + 1) * aDimension;
// JacCoeff array must be sized based on WorkDegrees
const Standard_Integer aWorkDegreeU = myJacobiU->WorkDegree();
const Standard_Integer aWorkDegreeV = myJacobiV->WorkDegree();
const Standard_Integer aCoeffCount = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
TColStd_Array1OfReal aJacCoeff(0, aCoeffCount - 1);
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = Sin(i * 0.1);
}
EXPECT_NO_THROW({
Standard_Real aMaxErrV =
aDoubleJac.MaxErrorV(aDimension, aDegreeU, aDegreeV, aDJacCoeff, aJacCoeff);
EXPECT_GE(aMaxErrV, 0.0) << "MaxErrorV should be non-negative";
EXPECT_FALSE(Precision::IsInfinite(aMaxErrV)) << "MaxErrorV should be finite";
}) << "MaxErrorV calculation failed";
}
// Test general MaxError calculation
TEST_F(PLibDoubleJacobiPolynomialTest, MaxError)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
const Standard_Integer aDimension = 1;
const Standard_Integer aMinDegreeU = 2, aMaxDegreeU = 5;
const Standard_Integer aMinDegreeV = 4, aMaxDegreeV = 7; // MinDegreeV must be >= MinV=4
const Standard_Integer aDJacCoeff = (aMaxDegreeU + 1) * aDimension;
const Standard_Real anError = 1e-6;
// JacCoeff array must be sized based on WorkDegrees
const Standard_Integer aWorkDegreeU = myJacobiU->WorkDegree();
const Standard_Integer aWorkDegreeV = myJacobiV->WorkDegree();
const Standard_Integer aCoeffCount = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
TColStd_Array1OfReal aJacCoeff(0, aCoeffCount - 1);
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = Sin(i * 0.1);
}
EXPECT_NO_THROW({
Standard_Real aMaxErr = aDoubleJac.MaxError(aDimension,
aMinDegreeU,
aMaxDegreeU,
aMinDegreeV,
aMaxDegreeV,
aDJacCoeff,
aJacCoeff,
anError);
EXPECT_GE(aMaxErr, 0.0) << "MaxError should be non-negative";
EXPECT_FALSE(Precision::IsInfinite(aMaxErr)) << "MaxError should be finite";
}) << "MaxError calculation failed";
}
// Test degree reduction
TEST_F(PLibDoubleJacobiPolynomialTest, ReduceDegree)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
const Standard_Integer aDimension = 1;
const Standard_Integer aMinDegreeU = 2, aMaxDegreeU = 6; // Must be >= MinU=2
const Standard_Integer aMinDegreeV = 4, aMaxDegreeV = 7; // Must be >= MinV=4
const Standard_Integer aDJacCoeff = (aMaxDegreeU + 1) * aDimension;
const Standard_Real anEpmsCut = 1e-8;
// JacCoeff array must be sized based on WorkDegrees and use 0-based indexing
const Standard_Integer aWorkDegreeU = myJacobiU->WorkDegree();
const Standard_Integer aWorkDegreeV = myJacobiV->WorkDegree();
const Standard_Integer aCoeffCount = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
TColStd_Array1OfReal aJacCoeff(0, aCoeffCount - 1);
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = 1.0 / (i + 10); // Small decreasing values
}
Standard_Real aMaxError = -1.0;
Standard_Integer aNewDegreeU = -1, aNewDegreeV = -1;
EXPECT_NO_THROW({
aDoubleJac.ReduceDegree(aDimension,
aMinDegreeU,
aMaxDegreeU,
aMinDegreeV,
aMaxDegreeV,
aDJacCoeff,
aJacCoeff,
anEpmsCut,
aMaxError,
aNewDegreeU,
aNewDegreeV);
}) << "ReduceDegree failed";
// Verify results are reasonable
EXPECT_LE(aNewDegreeU, aMaxDegreeU) << "New U degree should not exceed max";
EXPECT_GE(aNewDegreeU, aMinDegreeU) << "New U degree should be at least min";
EXPECT_LE(aNewDegreeV, aMaxDegreeV) << "New V degree should not exceed max";
EXPECT_GE(aNewDegreeV, aMinDegreeV) << "New V degree should be at least min";
EXPECT_GE(aMaxError, 0.0) << "Max error should be non-negative";
EXPECT_FALSE(Precision::IsInfinite(aMaxError)) << "Max error should be finite";
}
// Test average error calculation
TEST_F(PLibDoubleJacobiPolynomialTest, AverageError)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
const Standard_Integer aDimension = 2;
const Standard_Integer aDegreeU = 4;
const Standard_Integer aDegreeV = 3;
const Standard_Integer aDJacCoeff = 0; // For 0-based arrays, start offset should be 0
// JacCoeff array must be sized based on WorkDegrees and use 0-based indexing
const Standard_Integer aWorkDegreeU = myJacobiU->WorkDegree();
const Standard_Integer aWorkDegreeV = myJacobiV->WorkDegree();
const Standard_Integer aCoeffCount = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
TColStd_Array1OfReal aJacCoeff(0, aCoeffCount - 1);
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = Sin(i * 0.1);
}
EXPECT_NO_THROW({
Standard_Real aAvgErr =
aDoubleJac.AverageError(aDimension, aDegreeU, aDegreeV, aDJacCoeff, aJacCoeff);
EXPECT_GE(aAvgErr, 0.0) << "Average error should be non-negative";
EXPECT_FALSE(Precision::IsInfinite(aAvgErr)) << "Average error should be finite";
}) << "AverageError calculation failed";
}
// Test coefficient conversion to canonical base
TEST_F(PLibDoubleJacobiPolynomialTest, CoefficientConversion)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
const Standard_Integer aDimension = 3;
const Standard_Integer aDegreeU = 3;
const Standard_Integer aDegreeV = 2;
// JacCoeff array must be sized based on WorkDegrees, not input degrees
const Standard_Integer aWorkDegreeU = myJacobiU->WorkDegree();
const Standard_Integer aWorkDegreeV = myJacobiV->WorkDegree();
const Standard_Integer aJacCoeffSize = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
// JacCoeff uses 0-based indexing as per the implementation
TColStd_Array1OfReal aJacCoeff(0, aJacCoeffSize - 1);
// Initialize with test data - use simple pattern for valid coefficients
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = Sin(i * 0.1);
}
// Output coefficients array is sized based on actual degrees
const Standard_Integer aCoeffCount = (aDegreeU + 1) * (aDegreeV + 1) * aDimension;
TColStd_Array1OfReal aCoefficients(0, aCoeffCount - 1);
EXPECT_NO_THROW({
aDoubleJac.WDoubleJacobiToCoefficients(aDimension,
aDegreeU,
aDegreeV,
aJacCoeff,
aCoefficients);
}) << "Coefficient conversion failed";
// Verify output coefficients are finite
for (Standard_Integer i = aCoefficients.Lower(); i <= aCoefficients.Upper(); i++)
{
EXPECT_FALSE(Precision::IsInfinite(aCoefficients(i)))
<< "Converted coefficient should be finite at index " << i;
}
}
// Test with mismatched degrees
TEST_F(PLibDoubleJacobiPolynomialTest, MismatchedDegrees)
{
Handle(PLib_JacobiPolynomial) aJacU_Low = new PLib_JacobiPolynomial(5, GeomAbs_C0);
Handle(PLib_JacobiPolynomial) aJacV_High = new PLib_JacobiPolynomial(20, GeomAbs_C1);
EXPECT_NO_THROW({
PLib_DoubleJacobiPolynomial aDoubleJac(aJacU_Low, aJacV_High);
// Should handle mismatched degrees gracefully
EXPECT_FALSE(aDoubleJac.U().IsNull());
EXPECT_FALSE(aDoubleJac.V().IsNull());
}) << "Constructor should handle mismatched degrees";
}
// Test accessor consistency
TEST_F(PLibDoubleJacobiPolynomialTest, AccessorConsistency)
{
PLib_DoubleJacobiPolynomial aDoubleJac(myJacobiU, myJacobiV);
// Test that accessors return consistent results
Handle(PLib_JacobiPolynomial) aReturnedU = aDoubleJac.U();
Handle(PLib_JacobiPolynomial) aReturnedV = aDoubleJac.V();
Handle(TColStd_HArray1OfReal) aTabMaxU = aDoubleJac.TabMaxU();
Handle(TColStd_HArray1OfReal) aTabMaxV = aDoubleJac.TabMaxV();
// Multiple calls should return same handles
EXPECT_EQ(aReturnedU.get(), aDoubleJac.U().get()) << "U accessor should be consistent";
EXPECT_EQ(aReturnedV.get(), aDoubleJac.V().get()) << "V accessor should be consistent";
EXPECT_EQ(aTabMaxU.get(), aDoubleJac.TabMaxU().get()) << "TabMaxU accessor should be consistent";
EXPECT_EQ(aTabMaxV.get(), aDoubleJac.TabMaxV().get()) << "TabMaxV accessor should be consistent";
// Verify TabMax arrays are properly sized and contain valid data
if (!aTabMaxU.IsNull())
{
const TColStd_Array1OfReal& anArrU = aTabMaxU->Array1();
for (Standard_Integer i = anArrU.Lower(); i <= anArrU.Upper(); i++)
{
EXPECT_GT(anArrU(i), 0.0) << "TabMaxU values should be positive";
EXPECT_FALSE(Precision::IsInfinite(anArrU(i))) << "TabMaxU values should be finite";
}
}
if (!aTabMaxV.IsNull())
{
const TColStd_Array1OfReal& anArrV = aTabMaxV->Array1();
for (Standard_Integer i = anArrV.Lower(); i <= anArrV.Upper(); i++)
{
EXPECT_GT(anArrV(i), 0.0) << "TabMaxV values should be positive";
EXPECT_FALSE(Precision::IsInfinite(anArrV(i))) << "TabMaxV values should be finite";
}
}
}
// Stress test with large degrees
TEST_F(PLibDoubleJacobiPolynomialTest, StressTest)
{
Handle(PLib_JacobiPolynomial) aJacU_Large = new PLib_JacobiPolynomial(25, GeomAbs_C1);
Handle(PLib_JacobiPolynomial) aJacV_Large = new PLib_JacobiPolynomial(20, GeomAbs_C2);
EXPECT_NO_THROW({
PLib_DoubleJacobiPolynomial aDoubleJac(aJacU_Large, aJacV_Large);
// Test basic operations don't crash with large degrees
const Standard_Integer aDimension = 1;
const Standard_Integer aDegreeU = 15;
const Standard_Integer aDegreeV = 12;
// Array must be sized based on WorkDegrees for proper method operation
const Standard_Integer aWorkDegreeU = aJacU_Large->WorkDegree();
const Standard_Integer aWorkDegreeV = aJacV_Large->WorkDegree();
const Standard_Integer aCoeffCount = (aWorkDegreeU + 1) * (aWorkDegreeV + 1) * aDimension;
const Standard_Integer aDJacCoeff = 0; // For 0-based arrays
TColStd_Array1OfReal aJacCoeff(0, aCoeffCount - 1);
for (Standard_Integer i = aJacCoeff.Lower(); i <= aJacCoeff.Upper(); i++)
{
aJacCoeff(i) = Sin(i * 0.1);
}
Standard_Real aMaxErrU =
aDoubleJac.MaxErrorU(aDimension, aDegreeU, aDegreeV, aDJacCoeff, aJacCoeff);
Standard_Real aMaxErrV =
aDoubleJac.MaxErrorV(aDimension, aDegreeU, aDegreeV, aDJacCoeff, aJacCoeff);
Standard_Real aAvgErr =
aDoubleJac.AverageError(aDimension, aDegreeU, aDegreeV, aDJacCoeff, aJacCoeff);
EXPECT_GE(aMaxErrU, 0.0) << "MaxErrorU should be non-negative";
EXPECT_GE(aMaxErrV, 0.0) << "MaxErrorV should be non-negative";
EXPECT_GE(aAvgErr, 0.0) << "AverageError should be non-negative";
}) << "Large degree operations should complete without crashing";
}

View File

@@ -6,9 +6,6 @@ set(OCCT_PLib_FILES
PLib.hxx
PLib_Base.cxx
PLib_Base.hxx
PLib_DoubleJacobiPolynomial.cxx
PLib_DoubleJacobiPolynomial.hxx
PLib_DoubleJacobiPolynomial.lxx
PLib_HermitJacobi.cxx
PLib_HermitJacobi.hxx
PLib_HermitJacobi.lxx

View File

@@ -1,345 +0,0 @@
// Created on: 1997-05-28
// Created by: Sergey SOKOLOV
// Copyright (c) 1997-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.
#include <math_Vector.hxx>
#include <PLib_DoubleJacobiPolynomial.hxx>
#include <PLib_JacobiPolynomial.hxx>
//=================================================================================================
PLib_DoubleJacobiPolynomial::PLib_DoubleJacobiPolynomial() {}
//=================================================================================================
PLib_DoubleJacobiPolynomial::PLib_DoubleJacobiPolynomial(
const Handle(PLib_JacobiPolynomial)& JacPolU,
const Handle(PLib_JacobiPolynomial)& JacPolV)
: myJacPolU(JacPolU),
myJacPolV(JacPolV)
{
Handle(TColStd_HArray1OfReal) TabMaxU =
new TColStd_HArray1OfReal(0, JacPolU->WorkDegree() - 2 * (JacPolU->NivConstr() + 1));
JacPolU->MaxValue(TabMaxU->ChangeArray1());
myTabMaxU = TabMaxU;
Handle(TColStd_HArray1OfReal) TabMaxV =
new TColStd_HArray1OfReal(0, JacPolV->WorkDegree() - 2 * (JacPolV->NivConstr() + 1));
JacPolV->MaxValue(TabMaxV->ChangeArray1());
myTabMaxV = TabMaxV;
}
//=================================================================================================
Standard_Real PLib_DoubleJacobiPolynomial::MaxErrorU(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff) const
{
Standard_Integer ii, idim, dJac, MinU, MinV, WorkDegreeU, WorkDegreeV;
Standard_Real Bid0;
math_Vector MaxErrDim(1, Dimension, 0.);
MinU = 2 * (myJacPolU->NivConstr() + 1);
MinV = 2 * (myJacPolV->NivConstr() + 1);
WorkDegreeU = myJacPolU->WorkDegree();
WorkDegreeV = myJacPolV->WorkDegree();
Bid0 = myTabMaxV->Value(DegreeV - MinV);
for (idim = 1; idim <= Dimension; idim++)
{
dJac = dJacCoeff + (idim - 1) * (WorkDegreeU + 1) * (WorkDegreeV + 1);
for (ii = MinU; ii <= DegreeU; ii++)
{
MaxErrDim(idim) += (Abs(JacCoeff(ii + DegreeV * (WorkDegreeU + 1) + dJac))
* myTabMaxU->Value(ii - MinU) * Bid0);
}
}
return (MaxErrDim.Norm());
}
//=================================================================================================
Standard_Real PLib_DoubleJacobiPolynomial::MaxErrorV(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff) const
{
Standard_Integer jj, idim, dJac, MinU, MinV, WorkDegreeU, WorkDegreeV;
Standard_Real Bid0;
math_Vector MaxErrDim(1, Dimension, 0.);
MinU = 2 * (myJacPolU->NivConstr() + 1);
MinV = 2 * (myJacPolV->NivConstr() + 1);
WorkDegreeU = myJacPolU->WorkDegree();
WorkDegreeV = myJacPolV->WorkDegree();
Bid0 = myTabMaxU->Value(DegreeU - MinU);
for (idim = 1; idim <= Dimension; idim++)
{
dJac = dJacCoeff + (idim - 1) * (WorkDegreeU + 1) * (WorkDegreeV + 1);
for (jj = MinV; jj <= DegreeV; jj++)
{
MaxErrDim(idim) += (Abs(JacCoeff(DegreeU + jj * (WorkDegreeU + 1) + dJac))
* myTabMaxV->Value(jj - MinV) * Bid0);
}
}
return (MaxErrDim.Norm());
}
//=================================================================================================
Standard_Real PLib_DoubleJacobiPolynomial::MaxError(const Standard_Integer Dimension,
const Standard_Integer MinDegreeU,
const Standard_Integer MaxDegreeU,
const Standard_Integer MinDegreeV,
const Standard_Integer MaxDegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff,
const Standard_Real Error) const
{
Standard_Integer ii, jj, idim, dJac, MinU, MinV, WorkDegreeU, WorkDegreeV;
Standard_Real Bid0, Bid1;
math_Vector MaxErrDim(1, Dimension, 0.);
MinU = 2 * (myJacPolU->NivConstr() + 1);
MinV = 2 * (myJacPolV->NivConstr() + 1);
WorkDegreeU = myJacPolU->WorkDegree();
WorkDegreeV = myJacPolV->WorkDegree();
//------------------- Calcul du majorant de l'erreur max ---------------
//----- lorsque sont enleves les coeff. d'indices MinDegreeU a MaxDegreeU ------
//---------------- en U et d'indices MinDegreeV a MaxDegreeV en V --------------
for (idim = 1; idim <= Dimension; idim++)
{
dJac = dJacCoeff + (idim - 1) * (WorkDegreeU + 1) * (WorkDegreeV + 1);
Bid1 = 0.;
for (jj = MinDegreeV; jj <= MaxDegreeV; jj++)
{
Bid0 = 0.;
for (ii = MinDegreeU; ii <= MaxDegreeU; ii++)
{
Bid0 += fabs(JacCoeff(ii + jj * (WorkDegreeU + 1) + dJac)) * myTabMaxU->Value(ii - MinU);
}
Bid1 += Bid0 * myTabMaxV->Value(jj - MinV);
}
MaxErrDim(idim) = Bid1;
}
//----------------------- Calcul de l' erreur max ----------------------
math_Vector MaxErr2(1, 2);
MaxErr2(1) = Error;
MaxErr2(2) = MaxErrDim.Norm();
return (MaxErr2.Norm());
}
//=================================================================================================
void PLib_DoubleJacobiPolynomial::ReduceDegree(const Standard_Integer Dimension,
const Standard_Integer MinDegreeU,
const Standard_Integer MaxDegreeU,
const Standard_Integer MinDegreeV,
const Standard_Integer MaxDegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff,
const Standard_Real EpmsCut,
Standard_Real& MaxError,
Standard_Integer& NewDegreeU,
Standard_Integer& NewDegreeV) const
{
Standard_Integer NewU, NewV;
Standard_Real ErrU, ErrV;
NewU = MaxDegreeU;
NewV = MaxDegreeV;
math_Vector MaxErr2(1, 2);
MaxError = 0.0; // Initialize MaxError
//**********************************************************************
//-------------------- Coupure des coefficients ------------------------
//**********************************************************************
do
{
//------------------- Calcul du majorant de l'erreur max ---------------
//----- lorsque sont enleves les coeff. d'indices MinU a NewU ------
//---------------- en U, le degre en V etant fixe a NewV -----------------
if (NewV > MinDegreeV)
ErrV = MaxErrorU(Dimension, NewU, NewV, dJacCoeff, JacCoeff);
else
{
ErrV = 2 * EpmsCut;
}
//------------------- Calcul du majorant de l'erreur max ---------------
//----- lorsque sont enleves les coeff. d'indices MinV a NewV ------
//---------------- en V, le degre en U etant fixe a NewU -----------------
if (NewU > MinDegreeU)
ErrU = MaxErrorV(Dimension, NewU, NewV, dJacCoeff, JacCoeff);
else
{
ErrU = 2 * EpmsCut;
}
//----------------------- Calcul de l' erreur max ----------------------
MaxErr2(1) = MaxError;
MaxErr2(2) = ErrU;
ErrU = MaxErr2.Norm();
MaxErr2(2) = ErrV;
ErrV = MaxErr2.Norm();
if (ErrU > ErrV)
{
if (ErrV < EpmsCut)
{
MaxError = ErrV;
NewV--;
}
}
else
{
if (ErrU < EpmsCut)
{
MaxError = ErrU;
NewU--;
}
}
} while ((ErrU > ErrV && ErrV <= EpmsCut) || (ErrV >= ErrU && ErrU <= EpmsCut));
//-------------------------- Recuperation des degres -------------------
NewDegreeU = Max(NewU, 1);
NewDegreeV = Max(NewV, 1);
}
//=================================================================================================
Standard_Real PLib_DoubleJacobiPolynomial::AverageError(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff) const
{
Standard_Integer ii, jj, idim, dJac, IDebU, IDebV, MinU, MinV, WorkDegreeU, WorkDegreeV;
Standard_Real Bid0, Bid1, AverageErr;
//----------------------------- Initialisations ------------------------
IDebU = 2 * (myJacPolU->NivConstr() + 1);
IDebV = 2 * (myJacPolV->NivConstr() + 1);
MinU = Max(IDebU, DegreeU);
MinV = Max(IDebV, DegreeV);
WorkDegreeU = myJacPolU->WorkDegree();
WorkDegreeV = myJacPolV->WorkDegree();
Bid0 = 0.;
//------------------ Calcul du majorant de l'erreur moyenne ------------
//----- lorsque sont enleves les coeff. d'indices DegreeU a WorkDegreeU ------
//---------------- en U et d'indices DegreeV a WorkDegreeV en V --------------
for (idim = 1; idim <= Dimension; idim++)
{
dJac = dJacCoeff + (idim - 1) * (WorkDegreeU + 1) * (WorkDegreeV + 1);
for (jj = MinV; jj <= WorkDegreeV; jj++)
{
for (ii = IDebU; ii <= WorkDegreeU; ii++)
{
Bid1 = JacCoeff(ii + jj * (WorkDegreeU + 1) + dJac);
Bid0 += Bid1 * Bid1;
}
}
for (jj = IDebV; jj <= MinV - 1; jj++)
{
for (ii = MinU; ii <= WorkDegreeU; ii++)
{
Bid1 = JacCoeff(ii + jj * (WorkDegreeU + 1) + dJac);
Bid0 += Bid1 * Bid1;
}
}
}
AverageErr = sqrt(Bid0 / 4);
return (AverageErr);
}
//=================================================================================================
void PLib_DoubleJacobiPolynomial::WDoubleJacobiToCoefficients(
const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const TColStd_Array1OfReal& JacCoeff,
TColStd_Array1OfReal& Coefficients) const
{
Standard_Integer iu, iv, idim, WorkDegreeU, WorkDegreeV;
Coefficients.Init(0.);
WorkDegreeU = myJacPolU->WorkDegree();
WorkDegreeV = myJacPolV->WorkDegree();
TColStd_Array1OfReal Aux1(0, (DegreeU + 1) * (DegreeV + 1) * Dimension - 1);
TColStd_Array1OfReal Aux2(0, (DegreeU + 1) * (DegreeV + 1) * Dimension - 1);
for (iu = 0; iu <= DegreeU; iu++)
{
for (iv = 0; iv <= DegreeV; iv++)
{
for (idim = 1; idim <= Dimension; idim++)
{
Aux1(idim - 1 + iv * Dimension + iu * Dimension * (DegreeV + 1)) = JacCoeff(
iu + iv * (WorkDegreeU + 1) + (idim - 1) * (WorkDegreeU + 1) * (WorkDegreeV + 1));
}
}
}
// Passage dans canonique en u.
myJacPolU->ToCoefficients(Dimension * (DegreeV + 1), DegreeU, Aux1, Aux2);
// Permutation des u et des v.
for (iu = 0; iu <= DegreeU; iu++)
{
for (iv = 0; iv <= DegreeV; iv++)
{
for (idim = 1; idim <= Dimension; idim++)
{
Aux1(idim - 1 + iu * Dimension + iv * Dimension * (DegreeU + 1)) =
Aux2(idim - 1 + iv * Dimension + iu * Dimension * (DegreeV + 1));
}
}
}
// Passage dans canonique en v.
myJacPolV->ToCoefficients(Dimension * (DegreeU + 1), DegreeV, Aux1, Aux2);
// Permutation des u et des v.
for (iu = 0; iu <= DegreeU; iu++)
{
for (iv = 0; iv <= DegreeV; iv++)
{
for (idim = 1; idim <= Dimension; idim++)
{
Coefficients(iu + iv * (DegreeU + 1) + (idim - 1) * (DegreeU + 1) * (DegreeV + 1)) =
Aux2(idim - 1 + iu * Dimension + iv * Dimension * (DegreeU + 1));
}
}
}
}

View File

@@ -1,105 +0,0 @@
// Created on: 1997-05-27
// Created by: Sergey SOKOLOV
// Copyright (c) 1997-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 _PLib_DoubleJacobiPolynomial_HeaderFile
#define _PLib_DoubleJacobiPolynomial_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Standard_Integer.hxx>
class PLib_JacobiPolynomial;
class PLib_DoubleJacobiPolynomial
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT PLib_DoubleJacobiPolynomial();
Standard_EXPORT PLib_DoubleJacobiPolynomial(const Handle(PLib_JacobiPolynomial)& JacPolU,
const Handle(PLib_JacobiPolynomial)& JacPolV);
Standard_EXPORT Standard_Real MaxErrorU(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff) const;
Standard_EXPORT Standard_Real MaxErrorV(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff) const;
Standard_EXPORT Standard_Real MaxError(const Standard_Integer Dimension,
const Standard_Integer MinDegreeU,
const Standard_Integer MaxDegreeU,
const Standard_Integer MinDegreeV,
const Standard_Integer MaxDegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff,
const Standard_Real Error) const;
Standard_EXPORT void ReduceDegree(const Standard_Integer Dimension,
const Standard_Integer MinDegreeU,
const Standard_Integer MaxDegreeU,
const Standard_Integer MinDegreeV,
const Standard_Integer MaxDegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff,
const Standard_Real EpmsCut,
Standard_Real& MaxError,
Standard_Integer& NewDegreeU,
Standard_Integer& NewDegreeV) const;
Standard_EXPORT Standard_Real AverageError(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const Standard_Integer dJacCoeff,
const TColStd_Array1OfReal& JacCoeff) const;
Standard_EXPORT void WDoubleJacobiToCoefficients(const Standard_Integer Dimension,
const Standard_Integer DegreeU,
const Standard_Integer DegreeV,
const TColStd_Array1OfReal& JacCoeff,
TColStd_Array1OfReal& Coefficients) const;
//! returns myJacPolU;
Handle(PLib_JacobiPolynomial) U() const;
//! returns myJacPolV;
Handle(PLib_JacobiPolynomial) V() const;
//! returns myTabMaxU;
Handle(TColStd_HArray1OfReal) TabMaxU() const;
//! returns myTabMaxV;
Handle(TColStd_HArray1OfReal) TabMaxV() const;
protected:
private:
Handle(PLib_JacobiPolynomial) myJacPolU;
Handle(PLib_JacobiPolynomial) myJacPolV;
Handle(TColStd_HArray1OfReal) myTabMaxU;
Handle(TColStd_HArray1OfReal) myTabMaxV;
};
#include <PLib_DoubleJacobiPolynomial.lxx>
#endif // _PLib_DoubleJacobiPolynomial_HeaderFile

View File

@@ -1,38 +0,0 @@
// Created on: 1997-06-06
// Created by: Sergey SOKOLOV
// Copyright (c) 1997-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.
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
inline Handle(PLib_JacobiPolynomial) PLib_DoubleJacobiPolynomial::U() const
{
return myJacPolU;
}
inline Handle(PLib_JacobiPolynomial) PLib_DoubleJacobiPolynomial::V() const
{
return myJacPolV;
}
inline Handle(TColStd_HArray1OfReal) PLib_DoubleJacobiPolynomial::TabMaxU() const
{
return myTabMaxU;
}
inline Handle(TColStd_HArray1OfReal) PLib_DoubleJacobiPolynomial::TabMaxV() const
{
return myTabMaxV;
}