MCPcopy Create free account
hub / github.com/davisking/dlib / normalize

Function normalize

dlib/matrix/matrix_math_functions.h:238–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236 typename EXP
237 >
238 const matrix_op<op_normalize<EXP> > normalize (
239 const matrix_exp<EXP>& m
240 )
241 {
242 // you can only compute normalized matrices that contain floats, doubles or long doubles.
243 COMPILE_TIME_ASSERT((
244 is_same_type<typename EXP::type,float>::value == true ||
245 is_same_type<typename EXP::type,double>::value == true ||
246 is_same_type<typename EXP::type,long double>::value == true
247 ));
248
249
250 typedef op_normalize<EXP> op;
251 typename EXP::type temp = std::sqrt(sum(squared(m)));
252 if (temp != 0.0)
253 temp = 1.0/temp;
254
255 return matrix_op<op>(op(m.ref(),temp));
256 }
257
258// ----------------------------------------------------------------------------------------
259

Callers

nothing calls this directly

Calls 3

squaredFunction · 0.85
sumFunction · 0.70
sqrtFunction · 0.50

Tested by

no test coverage detected