Skip to content
Snippets Groups Projects
Commit 61b5aa8d authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed bug in lpNorm

parent f859baec
No related branches found
No related tags found
No related merge requests found
......@@ -106,7 +106,7 @@ auto StaticExpressionLpNorm( const Expression& expression, const Real& p )
}
auto aux = TNL::pow( expression[ 0 ], p );
for( int i = 1; i < expression.getSize(); i++ )
aux += TNL::pow( expression[ i ], p );
aux += TNL::pow( TNL::abs( expression[ i ] ), p );
return aux;
}
......
......@@ -145,7 +145,7 @@ auto ExpressionLpNorm( const Expression& expression, const Real& p ) ->
auto volatileReduction = [=] __cuda_callable__ ( volatile ResultType& a, volatile ResultType& b ) { a += b; };
return Algorithms::Reduction< typename Expression::DeviceType >::reduce( expression.getSize(), reduction, volatileReduction, fetch, ( ResultType ) 0.0 );
}
auto fetch = [=] __cuda_callable__ ( IndexType i ) { return TNL::pow( expression[ i ], p ); };
auto fetch = [=] __cuda_callable__ ( IndexType i ) { return TNL::pow( TNL::abs( expression[ i ] ), p ); };
auto reduction = [=] __cuda_callable__ ( ResultType& a, const ResultType& b ) { a += b; };
auto volatileReduction = [=] __cuda_callable__ ( volatile ResultType& a, volatile ResultType& b ) { a += b; };
return Algorithms::Reduction< typename Expression::DeviceType >::reduce( expression.getSize(), reduction, volatileReduction, fetch, ( ResultType ) 0.0 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment