mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add boolField specializations: negate(), component()
ENH: added scalarField hypot() function
This commit is contained in:
committed by
Andrew Heather
parent
b465592ee2
commit
28a9cde028
3
applications/test/field1/Make/files
Normal file
3
applications/test/field1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-field1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-field1
|
||||
2
applications/test/field1/Make/options
Normal file
2
applications/test/field1/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
70
applications/test/field1/Test-field1.C
Normal file
70
applications/test/field1/Test-field1.C
Normal file
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Simple field tests
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "primitiveFields.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
scalarField sfield(10, one());
|
||||
|
||||
forAll(sfield, i)
|
||||
{
|
||||
sfield[i] = (i % 4) ? i : 0;
|
||||
}
|
||||
|
||||
Info<< "scalarField: " << sfield << nl;
|
||||
sfield.negate();
|
||||
|
||||
Info<< "negated: " << sfield << nl;
|
||||
|
||||
// Does not compile (ambiguous)
|
||||
// boolField lfield(10, one());
|
||||
|
||||
boolField lfield(10, true);
|
||||
|
||||
forAll(lfield, i)
|
||||
{
|
||||
lfield[i] = (i % 4) ? i : 0;
|
||||
}
|
||||
|
||||
Info<< "boolField: " << lfield << nl;
|
||||
lfield.negate();
|
||||
|
||||
Info<< "negated: " << lfield << nl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -656,6 +656,7 @@ fields/cloud/cloud.C
|
||||
Fields = fields/Fields
|
||||
|
||||
$(Fields)/Field/FieldBase.C
|
||||
$(Fields)/boolField/boolField.C
|
||||
$(Fields)/labelField/labelField.C
|
||||
$(Fields)/labelField/labelIOField.C
|
||||
$(Fields)/labelField/labelFieldIOField.C
|
||||
|
||||
@ -498,6 +498,17 @@ Foam::dimensionSet Foam::atan2(const dimensionSet& ds1, const dimensionSet& ds2)
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionSet Foam::hypot(const dimensionSet& ds1, const dimensionSet& ds2)
|
||||
{
|
||||
if (dimensionSet::debug)
|
||||
{
|
||||
checkDims("hypot(a, b)", ds1, ds2);
|
||||
}
|
||||
|
||||
return ds1;
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionSet Foam::transform(const dimensionSet& ds)
|
||||
{
|
||||
return ds;
|
||||
|
||||
@ -330,9 +330,12 @@ dimensionSet inv(const dimensionSet& ds);
|
||||
//- Check the argument is dimensionless (for transcendental functions)
|
||||
dimensionSet trans(const dimensionSet& ds);
|
||||
|
||||
//- Check that the arguments have the same dimensions
|
||||
//- Arguments need the same dimensions. Return dimensionless.
|
||||
dimensionSet atan2(const dimensionSet& ds1, const dimensionSet& ds2);
|
||||
|
||||
//- Arguments need the same dimensions. Does not change the dimension.
|
||||
dimensionSet hypot(const dimensionSet& ds1, const dimensionSet& ds2);
|
||||
|
||||
//- Return the argument; transformations do not change the dimensions
|
||||
dimensionSet transform(const dimensionSet& ds);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -162,21 +162,6 @@ dimensionedScalar cbrt(const dimensionedScalar& ds)
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar hypot
|
||||
(
|
||||
const dimensionedScalar& x,
|
||||
const dimensionedScalar& y
|
||||
)
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
"hypot(" + x.name() + ',' + y.name() + ')',
|
||||
x.dimensions() + y.dimensions(),
|
||||
::hypot(x.value(), y.value())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar sign(const dimensionedScalar& ds)
|
||||
{
|
||||
return dimensionedScalar
|
||||
@ -337,6 +322,21 @@ dimensionedScalar atan2
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar hypot
|
||||
(
|
||||
const dimensionedScalar& x,
|
||||
const dimensionedScalar& y
|
||||
)
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
"hypot(" + x.name() + ',' + y.name() + ')',
|
||||
hypot(x.dimensions(), y.dimensions()),
|
||||
::hypot(x.value(), y.value())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -66,7 +66,6 @@ dimensionedScalar pow025(const dimensionedScalar&);
|
||||
|
||||
dimensionedScalar sqrt(const dimensionedScalar&);
|
||||
dimensionedScalar cbrt(const dimensionedScalar&);
|
||||
dimensionedScalar hypot(const dimensionedScalar&, const dimensionedScalar&);
|
||||
|
||||
dimensionedScalar sign(const dimensionedScalar&);
|
||||
dimensionedScalar pos(const dimensionedScalar&);
|
||||
@ -86,6 +85,7 @@ dimensionedScalar asin(const dimensionedScalar&);
|
||||
dimensionedScalar acos(const dimensionedScalar&);
|
||||
dimensionedScalar atan(const dimensionedScalar&);
|
||||
dimensionedScalar atan2(const dimensionedScalar&, const dimensionedScalar&);
|
||||
dimensionedScalar hypot(const dimensionedScalar&, const dimensionedScalar&);
|
||||
dimensionedScalar sinh(const dimensionedScalar&);
|
||||
dimensionedScalar cosh(const dimensionedScalar&);
|
||||
dimensionedScalar tanh(const dimensionedScalar&);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -98,6 +98,9 @@ BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -91,6 +91,9 @@ BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -69,10 +69,6 @@ Ostream& operator<<(Ostream&, const Field<Type>&);
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const tmp<Field<Type>>&);
|
||||
|
||||
// Basic Field types
|
||||
typedef Field<bool> boolField; //!< A Field of bools
|
||||
typedef Field<label> labelField; //!< A Field of labels
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Field Declaration
|
||||
@ -338,7 +334,8 @@ public:
|
||||
const UList<scalar>& weights
|
||||
);
|
||||
|
||||
//- Negate this field
|
||||
//- Negate this field (negative).
|
||||
// Inverts the state for a bool field.
|
||||
void negate();
|
||||
|
||||
//- Return a component field of the field
|
||||
|
||||
71
src/OpenFOAM/fields/Fields/boolField/boolField.C
Normal file
71
src/OpenFOAM/fields/Fields/boolField/boolField.C
Normal file
@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Specialisation of Field\<T\> for bool.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "boolField.H"
|
||||
#include "unitConversion.H"
|
||||
|
||||
#define TEMPLATE
|
||||
#include "FieldFunctionsM.C"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
void boolField::negate()
|
||||
{
|
||||
TFOR_ALL_F_OP_OP_F(bool, *this, =, !, bool, *this)
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
tmp<boolField> boolField::component(const direction) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
void boolField::replace(const direction, const boolUList& bf)
|
||||
{
|
||||
*this = bf;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "undefFieldFunctionsM.H"
|
||||
|
||||
// ************************************************************************* //
|
||||
72
src/OpenFOAM/fields/Fields/boolField/boolField.H
Normal file
72
src/OpenFOAM/fields/Fields/boolField/boolField.H
Normal file
@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::boolField
|
||||
|
||||
Description
|
||||
Specialisation of Field\<T\> for bool
|
||||
|
||||
SourceFiles
|
||||
boolField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef boolField_H
|
||||
#define boolField_H
|
||||
|
||||
#include "bool.H"
|
||||
#include "Field.H"
|
||||
|
||||
#define TEMPLATE
|
||||
#include "FieldFunctionsM.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
typedef Field<bool> boolField;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
void boolField::negate();
|
||||
|
||||
template<>
|
||||
tmp<boolField> boolField::component(const direction) const;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "undefFieldFunctionsM.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -47,6 +47,7 @@ tmp<labelField> labelField::component(const direction) const
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
void component
|
||||
(
|
||||
@ -58,6 +59,7 @@ void component
|
||||
lf = f;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
void labelField::replace(const direction, const labelUList& lf)
|
||||
{
|
||||
|
||||
@ -48,8 +48,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// labelField = defined in Field.H
|
||||
|
||||
typedef Field<label> labelField;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011 OpenFOAM Foundation
|
||||
@ -36,6 +36,7 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "boolField.H"
|
||||
#include "labelField.H"
|
||||
#include "scalarField.H"
|
||||
#include "vectorField.H"
|
||||
|
||||
@ -46,6 +46,7 @@ namespace Foam
|
||||
|
||||
template<class Type> class Field;
|
||||
|
||||
typedef Field<bool> boolField;
|
||||
typedef Field<label> labelField;
|
||||
typedef Field<scalar> scalarField;
|
||||
typedef Field<solveScalar> solveScalarField;
|
||||
|
||||
@ -131,6 +131,9 @@ BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_FUNCTION(scalar, scalar, pow3)
|
||||
|
||||
@ -101,6 +101,9 @@ BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
|
||||
|
||||
BINARY_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
BINARY_TYPE_FUNCTION(scalar, scalar, scalar, hypot)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -417,6 +417,25 @@ Foam::orientedType Foam::atan2
|
||||
}
|
||||
|
||||
|
||||
Foam::orientedType Foam::hypot
|
||||
(
|
||||
const orientedType& ot1,
|
||||
const orientedType& ot2
|
||||
)
|
||||
{
|
||||
if (!orientedType::checkType(ot1, ot2))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Operator hypot is undefined for "
|
||||
<< orientedType::orientedOptionNames[ot1.oriented()] << " and "
|
||||
<< orientedType::orientedOptionNames[ot2.oriented()] << "types"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return ot1;
|
||||
}
|
||||
|
||||
|
||||
Foam::orientedType Foam::transform(const orientedType& ot)
|
||||
{
|
||||
return ot;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -179,6 +179,7 @@ orientedType inv(const orientedType& ot);
|
||||
|
||||
orientedType trans(const orientedType& ot);
|
||||
orientedType atan2(const orientedType& ot1, const orientedType& ot2);
|
||||
orientedType hypot(const orientedType& ot1, const orientedType& ot2);
|
||||
orientedType transform(const orientedType& ot);
|
||||
|
||||
orientedType operator-(const orientedType& ot);
|
||||
|
||||
@ -205,51 +205,50 @@ inline Scalar component(const Scalar s, const direction)
|
||||
}
|
||||
|
||||
|
||||
//- Return 1 if s is positive or 0 otherwise -1
|
||||
//- Return 1 if s is greater_equal zero, or otherwise -1
|
||||
inline Scalar sign(const Scalar s)
|
||||
{
|
||||
return (s >= 0)? 1: -1;
|
||||
}
|
||||
|
||||
|
||||
//- Return 1 if s is positive but not 0
|
||||
//- Return 1 if s is greater than zero, otherwise 1
|
||||
inline Scalar pos(const Scalar s)
|
||||
{
|
||||
return (s > 0)? 1: 0;
|
||||
}
|
||||
|
||||
|
||||
//- Return 1 if s is positive or 0
|
||||
//- Return 1 if s is greater_equal zero, or otherwise 0
|
||||
inline Scalar pos0(const Scalar s)
|
||||
{
|
||||
return (s >= 0)? 1: 0;
|
||||
}
|
||||
|
||||
|
||||
//- Return 1 if s is negative but not 0
|
||||
//- Return 1 if s is less than zero, or otherwise 0
|
||||
inline Scalar neg(const Scalar s)
|
||||
{
|
||||
return (s < 0)? 1: 0;
|
||||
}
|
||||
|
||||
|
||||
//- Return 1 if s is negative or 0
|
||||
//- Return 1 if s is less_equal zero, or otherwise 0
|
||||
inline Scalar neg0(const Scalar s)
|
||||
{
|
||||
return (s <= 0)? 1: 0;
|
||||
}
|
||||
|
||||
|
||||
//- Return the positive part of s
|
||||
//- Return the positive part of s, otherwise zero. Same as max(0, s).
|
||||
inline Scalar posPart(const Scalar s)
|
||||
{
|
||||
return (s > 0)? s: 0;
|
||||
}
|
||||
|
||||
|
||||
//- Return the negative part of s.
|
||||
// Note: this function returns the actual negative part of s as a
|
||||
// negative number and does not change the sign
|
||||
//- Return the negative part of s, otherwise zero. Same as min(0, s).
|
||||
// Does not change the sign
|
||||
inline Scalar negPart(const Scalar s)
|
||||
{
|
||||
return (s < 0)? s: 0;
|
||||
|
||||
Reference in New Issue
Block a user