| 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 | |