Skip to content

Commit

Permalink
STYLE: Change template parameter name prefix N to V
Browse files Browse the repository at this point in the history
STYLE: Remove N as acceptable template parameter name prefix
  • Loading branch information
Leengit authored and dzenanz committed Feb 14, 2022
1 parent 0df9d43 commit 4b43536
Show file tree
Hide file tree
Showing 167 changed files with 2,264 additions and 2,283 deletions.
50 changes: 25 additions & 25 deletions Modules/Core/Common/include/itkCovariantVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace itk
* type held at each pixel in an Image or at each vertex of an Mesh.
* The template parameter T can be any data type that behaves like a
* primitive (or atomic) data type (int, short, float, complex).
* The NVectorDimension defines the number of components in the vector array.
* The VVectorDimension defines the number of components in the vector array.
*
* CovariantVector is not a dynamically extendible array like std::vector. It is
* intended to be used like a mathematical vector.
Expand Down Expand Up @@ -65,13 +65,13 @@ namespace itk
* \endsphinx
*/

template <typename T, unsigned int NVectorDimension = 3>
class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimension>
template <typename T, unsigned int VVectorDimension = 3>
class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, VVectorDimension>
{
public:
/** Standard class type aliases. */
using Self = CovariantVector;
using Superclass = FixedArray<T, NVectorDimension>;
using Superclass = FixedArray<T, VVectorDimension>;

/** ValueType can be used to declare a variable that is the same type
* as a data element held in an CovariantVector. */
Expand All @@ -82,19 +82,19 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
using ComponentType = T;

/** Dimension of the Space */
static constexpr unsigned int Dimension = NVectorDimension;
static constexpr unsigned int Dimension = VVectorDimension;

/** I am a covariant vector. */
using CovariantVectorType = Self;

/** The Array type from which this CovariantVector is derived. */
using BaseArray = FixedArray<T, NVectorDimension>;
using BaseArray = FixedArray<T, VVectorDimension>;

/** Get the dimension (size) of the vector. */
static unsigned int
GetCovariantVectorDimension()
{
return NVectorDimension;
return VVectorDimension;
}

/** Set a vnl_vector_ref referencing the same memory block. */
Expand Down Expand Up @@ -127,7 +127,7 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
/** Pass-through constructor for the Array base class. Implicit casting is
* performed to initialize constructor from any another one of datatype. */
template <typename TVectorValueType>
CovariantVector(const CovariantVector<TVectorValueType, NVectorDimension> & r)
CovariantVector(const CovariantVector<TVectorValueType, VVectorDimension> & r)
: BaseArray(r)
{}
CovariantVector(const ValueType r[Dimension])
Expand All @@ -137,22 +137,22 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
/** Assignment operator with implicit casting from another data type */
template <typename TCovariantVectorValueType>
Self &
operator=(const CovariantVector<TCovariantVectorValueType, NVectorDimension> & r)
operator=(const CovariantVector<TCovariantVectorValueType, VVectorDimension> & r)
{
BaseArray::operator=(r);
return *this;
}

/** Pass-through assignment operator for the Array base class. */
CovariantVector &
operator=(const ValueType r[NVectorDimension]);
operator=(const ValueType r[VVectorDimension]);

/** Scalar operator*=. Scales elements by a scalar. */
template <typename Tt>
inline const Self &
operator*=(const Tt & value)
{
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
(*this)[i] = static_cast<ValueType>((*this)[i] * value);
}
Expand All @@ -164,7 +164,7 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
const Self &
operator/=(const Tt & value)
{
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
(*this)[i] = static_cast<ValueType>((*this)[i] / value);
}
Expand Down Expand Up @@ -200,15 +200,15 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio

/** operator*. Performs the scalar product with a vector (contravariant).
* This scalar product is invariant under affine transformations */
ValueType operator*(const Vector<T, NVectorDimension> & other) const;
ValueType operator*(const Vector<T, VVectorDimension> & other) const;

/** Scalar operator*. Scale the elements of a vector by a scalar.
* Return a new vector. */
inline Self operator*(const ValueType & val) const
{
Self result;

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
result[i] = static_cast<ValueType>((*this)[i] * val);
}
Expand All @@ -223,7 +223,7 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
{
Self result;

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
result[i] = static_cast<ValueType>((*this)[i] / val);
}
Expand All @@ -238,7 +238,7 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
static unsigned int
GetNumberOfComponents()
{
return NVectorDimension;
return VVectorDimension;
}

/** Divides the covariant vector components by the norm and return the norm */
Expand All @@ -253,9 +253,9 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio
* Casting is done with C-Like rules */
template <typename TCoordRepB>
void
CastFrom(const CovariantVector<TCoordRepB, NVectorDimension> & pa)
CastFrom(const CovariantVector<TCoordRepB, VVectorDimension> & pa)
{
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
(*this)[i] = static_cast<T>(pa[i]);
}
Expand All @@ -264,17 +264,17 @@ class ITK_TEMPLATE_EXPORT CovariantVector : public FixedArray<T, NVectorDimensio

/** Premultiply Operator for product of a vector and a scalar.
* CovariantVector< T, N > = T * CovariantVector< T,N > */
template <typename T, unsigned int NVectorDimension>
inline CovariantVector<T, NVectorDimension> operator*(const T & scalar, const CovariantVector<T, NVectorDimension> & v)
template <typename T, unsigned int VVectorDimension>
inline CovariantVector<T, VVectorDimension> operator*(const T & scalar, const CovariantVector<T, VVectorDimension> & v)
{
return v.operator*(scalar);
}

/** Performs the scalar product of a covariant with a contravariant.
* This scalar product is invariant under affine transformations */
template <typename T, unsigned int NVectorDimension>
inline T operator*(const Vector<T, NVectorDimension> & contravariant,
const CovariantVector<T, NVectorDimension> & covariant)
template <typename T, unsigned int VVectorDimension>
inline T operator*(const Vector<T, VVectorDimension> & contravariant,
const CovariantVector<T, VVectorDimension> & covariant)
{
return covariant.operator*(contravariant);
}
Expand All @@ -289,9 +289,9 @@ ITKCommon_EXPORT void
CrossProduct(CovariantVector<int, 3>, const Vector<int, 3> &, const Vector<int, 3> &);


template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
inline void
swap(CovariantVector<T, NVectorDimension> & a, CovariantVector<T, NVectorDimension> & b)
swap(CovariantVector<T, VVectorDimension> & a, CovariantVector<T, VVectorDimension> & b)
{
a.swap(b);
}
Expand Down
84 changes: 42 additions & 42 deletions Modules/Core/Common/include/itkCovariantVector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,160 +28,160 @@ CovariantVector<T, TVectorDimension>::CovariantVector(const ValueType & r)
: Superclass{ r }
{}

template <typename T, unsigned int NVectorDimension>
CovariantVector<T, NVectorDimension> &
CovariantVector<T, NVectorDimension>::operator=(const ValueType r[NVectorDimension])
template <typename T, unsigned int VVectorDimension>
CovariantVector<T, VVectorDimension> &
CovariantVector<T, VVectorDimension>::operator=(const ValueType r[VVectorDimension])
{
BaseArray::operator=(r);
return *this;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::operator+=(const Self & vec) -> const Self &
CovariantVector<T, VVectorDimension>::operator+=(const Self & vec) -> const Self &
{
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
(*this)[i] += vec[i];
}
return *this;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::operator-=(const Self & vec) -> const Self &
CovariantVector<T, VVectorDimension>::operator-=(const Self & vec) -> const Self &
{
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
(*this)[i] -= vec[i];
}
return *this;
}

template <typename T, unsigned int NVectorDimension>
CovariantVector<T, NVectorDimension>
CovariantVector<T, NVectorDimension>::operator-() const
template <typename T, unsigned int VVectorDimension>
CovariantVector<T, VVectorDimension>
CovariantVector<T, VVectorDimension>::operator-() const
{
Self result;

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
result[i] = -(*this)[i];
}
return result;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::operator+(const Self & vec) const -> Self
CovariantVector<T, VVectorDimension>::operator+(const Self & vec) const -> Self
{
Self result;

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
result[i] = (*this)[i] + vec[i];
}
return result;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::operator-(const Self & vec) const -> Self
CovariantVector<T, VVectorDimension>::operator-(const Self & vec) const -> Self
{
Self result;

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
result[i] = (*this)[i] - vec[i];
}
return result;
}

template <typename T, unsigned int NVectorDimension>
typename CovariantVector<T, NVectorDimension>::ValueType CovariantVector<T, NVectorDimension>::operator*(
template <typename T, unsigned int VVectorDimension>
typename CovariantVector<T, VVectorDimension>::ValueType CovariantVector<T, VVectorDimension>::operator*(
const Self & other) const
{
typename NumericTraits<T>::AccumulateType value = NumericTraits<T>::ZeroValue();
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
value += (*this)[i] * other[i];
}
return static_cast<ValueType>(value);
}

template <typename T, unsigned int NVectorDimension>
typename CovariantVector<T, NVectorDimension>::ValueType CovariantVector<T, NVectorDimension>::operator*(
const Vector<T, NVectorDimension> & other) const
template <typename T, unsigned int VVectorDimension>
typename CovariantVector<T, VVectorDimension>::ValueType CovariantVector<T, VVectorDimension>::operator*(
const Vector<T, VVectorDimension> & other) const
{
typename NumericTraits<T>::AccumulateType value = NumericTraits<T>::ZeroValue();
for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
value += (*this)[i] * other[i];
}
return value;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::GetSquaredNorm() const -> RealValueType
CovariantVector<T, VVectorDimension>::GetSquaredNorm() const -> RealValueType
{
RealValueType sum = NumericTraits<RealValueType>::ZeroValue();

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
const RealValueType value = (*this)[i];
sum += value * value;
}
return sum;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::GetNorm() const -> RealValueType
CovariantVector<T, VVectorDimension>::GetNorm() const -> RealValueType
{
return std::sqrt(this->GetSquaredNorm());
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, NVectorDimension>::Normalize() -> RealValueType
CovariantVector<T, VVectorDimension>::Normalize() -> RealValueType
{
const RealValueType norm = this->GetNorm();

for (unsigned int i = 0; i < NVectorDimension; ++i)
for (unsigned int i = 0; i < VVectorDimension; ++i)
{
(*this)[i] /= norm;
}

return norm;
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
void
CovariantVector<T, NVectorDimension>::SetVnlVector(const vnl_vector<T> & v)
CovariantVector<T, VVectorDimension>::SetVnlVector(const vnl_vector<T> & v)
{
for (unsigned int i = 0; i < v.size(); ++i)
{
(*this)[i] = v(i);
}
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
vnl_vector_ref<T>
CovariantVector<T, NVectorDimension>::GetVnlVector()
CovariantVector<T, VVectorDimension>::GetVnlVector()
{
return vnl_vector_ref<T>(NVectorDimension, this->GetDataPointer());
return vnl_vector_ref<T>(VVectorDimension, this->GetDataPointer());
}

template <typename T, unsigned int NVectorDimension>
template <typename T, unsigned int VVectorDimension>
vnl_vector<T>
CovariantVector<T, NVectorDimension>::GetVnlVector() const
CovariantVector<T, VVectorDimension>::GetVnlVector() const
{
// Return a vector_ref<>. This will be automatically converted to a
// vnl_vector<>. We have to use a const_cast<> which would normally
// be prohibited in a const method, but it is safe to do here
// because the cast to vnl_vector<> will ultimately copy the data.
return vnl_vector_ref<T>(NVectorDimension, const_cast<T *>(this->GetDataPointer()));
return vnl_vector_ref<T>(VVectorDimension, const_cast<T *>(this->GetDataPointer()));
}

} // end namespace itk
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ class ITK_TEMPLATE_EXPORT Image : public ImageBase<VImageDimension>
*
* \deprecated Use RebindImageType instead
*/
template <typename UPixelType, unsigned int NUImageDimension = VImageDimension>
template <typename UPixelType, unsigned int VUImageDimension = VImageDimension>
struct Rebind
{
using Type = itk::Image<UPixelType, NUImageDimension>;
using Type = itk::Image<UPixelType, VUImageDimension>;
};


template <typename UPixelType, unsigned int NUImageDimension = VImageDimension>
using RebindImageType = itk::Image<UPixelType, NUImageDimension>;
template <typename UPixelType, unsigned int VUImageDimension = VImageDimension>
using RebindImageType = itk::Image<UPixelType, VUImageDimension>;


/** Allocate the image memory. The size of the image must
Expand Down
Loading

0 comments on commit 4b43536

Please sign in to comment.