Skip to content
Snippets Groups Projects
Commit aab644a3 authored by Mark OLESEN's avatar Mark OLESEN Committed by Andrew Heather
Browse files

STYLE: eliminate complex constants that are duplications of pTraits

- eg pTraits<complex>::zero, pTraits<complex>::one instead.
  This is consistent with other primitives such as scalar, label etc.
parent 46dcba1b
No related branches found
No related tags found
No related merge requests found
...@@ -48,8 +48,8 @@ int main(int argc, char *argv[]) ...@@ -48,8 +48,8 @@ int main(int argc, char *argv[])
{ {
Info<< "complex() : " << complex() << nl Info<< "complex() : " << complex() << nl
<< "complex(zero) : " << complex(Zero) << nl << "complex(zero) : " << complex(Zero) << nl
<< "complex::zero : " << complex::zero << nl << "pTraits<complex>::zero : " << pTraits<complex>::zero << nl
<< "complex::one : " << complex::one << nl << "pTraits<complex>::one : " << pTraits<complex>::one << nl
<< "complex(scalar) : " << complex(3.14519) << nl << "complex(scalar) : " << complex(3.14519) << nl
<< nl; << nl;
...@@ -57,7 +57,6 @@ int main(int argc, char *argv[]) ...@@ -57,7 +57,6 @@ int main(int argc, char *argv[])
Info<< "std::complex : " << c1 << nl; Info<< "std::complex : " << c1 << nl;
Info<< "sin: " << std::sin(c1) << nl; Info<< "sin: " << std::sin(c1) << nl;
Info<< "complexVector::zero : " << complexVector::zero << nl Info<< "complexVector::zero : " << complexVector::zero << nl
<< "complexVector::one : " << complexVector::one << nl << "complexVector::one : " << complexVector::one << nl
<< nl; << nl;
...@@ -120,7 +119,7 @@ int main(int argc, char *argv[]) ...@@ -120,7 +119,7 @@ int main(int argc, char *argv[])
Info<< nl << "Elementary complex arithmetic operations:" << nl; Info<< nl << "Elementary complex arithmetic operations:" << nl;
{ {
complex a (6, 1); complex a(6, 1);
complex b = a; complex b = a;
Info << "Compound assignment operations:" << nl; Info << "Compound assignment operations:" << nl;
...@@ -160,13 +159,12 @@ int main(int argc, char *argv[]) ...@@ -160,13 +159,12 @@ int main(int argc, char *argv[])
// Scalar division // Scalar division
b = 1.0/b; b = 1.0/b;
Info<< "1/b (elementwise division):" << tab << b << nl; Info<< "1/b (elementwise division):" << tab << b << nl;
}
}
Info<< nl << "Other mathematical expressions:" << nl; Info<< nl << "Other mathematical expressions:" << nl;
{ {
complex a (4.3, -3.14); complex a(4.3, -3.14);
complex b (0, -4.3); complex b(0, -4.3);
Info<< "a=" << a << tab << "b=" << b << nl; Info<< "a=" << a << tab << "b=" << b << nl;
......
...@@ -44,37 +44,37 @@ const char* const Foam::complexVector::vsType::componentNames[] = ...@@ -44,37 +44,37 @@ const char* const Foam::complexVector::vsType::componentNames[] =
template<> template<>
const Foam::complexVector Foam::complexVector::vsType::zero const Foam::complexVector Foam::complexVector::vsType::zero
( (
complexVector::uniform(complex::zero) complexVector::uniform(pTraits<complex>::zero)
); );
template<> template<>
const Foam::complexVector Foam::complexVector::vsType::one const Foam::complexVector Foam::complexVector::vsType::one
( (
complexVector::uniform(complex::one) complexVector::uniform(pTraits<complex>::one)
); );
template<> template<>
const Foam::complexVector Foam::complexVector::vsType::max const Foam::complexVector Foam::complexVector::vsType::max
( (
complexVector::uniform(complex(VGREAT, VGREAT)) complexVector::uniform(pTraits<complex>::max)
); );
template<> template<>
const Foam::complexVector Foam::complexVector::vsType::min const Foam::complexVector Foam::complexVector::vsType::min
( (
complexVector::uniform(complex(-VGREAT, -VGREAT)) complexVector::uniform(pTraits<complex>::min)
); );
template<> template<>
const Foam::complexVector Foam::complexVector::vsType::rootMax const Foam::complexVector Foam::complexVector::vsType::rootMax
( (
complexVector::uniform(complex(ROOTVGREAT, ROOTVGREAT)) complexVector::uniform(pTraits<complex>::rootMax)
); );
template<> template<>
const Foam::complexVector Foam::complexVector::vsType::rootMin const Foam::complexVector Foam::complexVector::vsType::rootMin
( (
complexVector::uniform(complex(-ROOTVGREAT, -ROOTVGREAT)) complexVector::uniform(pTraits<complex>::rootMin)
); );
......
...@@ -30,12 +30,6 @@ License ...@@ -30,12 +30,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::complex Foam::complex::zero(0, 0);
const Foam::complex Foam::complex::one(1, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const Foam::pTraits<Foam::complex>::typeName = "complex"; const char* const Foam::pTraits<Foam::complex>::typeName = "complex";
const char* const Foam::pTraits<Foam::complex>::componentNames[] = {"re", "im"}; const char* const Foam::pTraits<Foam::complex>::componentNames[] = {"re", "im"};
......
...@@ -85,22 +85,6 @@ class complex ...@@ -85,22 +85,6 @@ class complex
public: public:
//- Component type
typedef complex cmptType;
// Static Data Members
//- The type name is "complex"
static constexpr const char* const typeName = "complex";
//- A complex zero (0,0)
static const complex zero;
//- A complex one (1,0)
static const complex one;
// Constructors // Constructors
//- Construct null as zero-initialized //- Construct null as zero-initialized
...@@ -273,12 +257,13 @@ public: ...@@ -273,12 +257,13 @@ public:
static const char* const typeName; static const char* const typeName;
static const char* const componentNames[]; static const char* const componentNames[];
static const complex zero;
static const complex one; static const complex zero; //!< complex (0,0)
static const complex max; static const complex one; //!< complex (1,0)
static const complex min; static const complex min; //!< complex (-VGREAT,-VGREAT)
static const complex rootMax; static const complex max; //!< complex (VGREAT,VGREAT)
static const complex rootMin; static const complex rootMin; //!< complex (-ROOTVGREAT, -ROOTVGREAT)
static const complex rootMax; //!< complex (ROOTVGREAT, ROOTVGREAT)
// Constructors // Constructors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment