cwVectOps.h : Added ones() and sub(scalar,v0,vn)

This commit is contained in:
kevin 2024-07-13 11:57:06 -04:00
parent c89f2cced3
commit c78cab6e56

View File

@ -72,6 +72,9 @@ namespace cw
void zero( T* v, unsigned n ) void zero( T* v, unsigned n )
{ fill(v,n,0); } { fill(v,n,0); }
template< typename T >
void ones( T* v, unsigned n )
{ fill(v,n,1); }
//================================================================================================================== //==================================================================================================================
// Compare // Compare
@ -324,6 +327,13 @@ namespace cw
v0[i] -= scalar; v0[i] -= scalar;
} }
template< typename T0, typename T1 >
void sub( const T0& scalar, T1* v0, unsigned n )
{
for(unsigned i=0; i<n; ++i)
v0[i] = scalar - v0[i];
}
template< typename T0, typename T1 > template< typename T0, typename T1 >
void sub( T0* y0, const T0* v0, const T1& scalar, unsigned n ) void sub( T0* y0, const T0* v0, const T1& scalar, unsigned n )
{ {