Skip to content

Commit dd03d5c

Browse files
author
Francois Keith
committed
Add a unary operator that computes the norm of a vector.
1 parent a9ff339 commit dd03d5c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/matrix/operator.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,25 @@ namespace dynamicgraph {
309309
REGISTER_UNARY_OP( Inverser<MatrixHomogeneous>, Inverse_of_matrixHomo);
310310
REGISTER_UNARY_OP( Inverser<MatrixTwist>, Inverse_of_matrixtwist);
311311

312+
313+
314+
struct Normalize
315+
: public UnaryOpHeader<dg::Vector,double>
316+
{
317+
void operator()( const dg::Vector& m, double& res ) const
318+
{ res = m.norm(); }
319+
320+
virtual std::string getDocString () const
321+
{
322+
std::string docString
323+
("Computes the norm of a vector\n"
324+
" - input vector\n"" - output double");
325+
return docString;
326+
}
327+
};
328+
REGISTER_UNARY_OP( Normalize, Norm_of_vector);
329+
330+
312331
struct InverserRotation
313332
: public UnaryOpHeader<MatrixRotation,MatrixRotation>
314333
{

0 commit comments

Comments
 (0)