Decent C++ for MathFloatVectorSum.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3895 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Nolan Check 2009-07-28 07:40:18 +00:00
parent 335a02b030
commit 989e5b7798
2 changed files with 4 additions and 8 deletions

View File

@ -19,6 +19,7 @@
#include "MathUtil.h"
#include <cmath>
#include <numeric>
namespace {
@ -160,14 +161,9 @@ inline void MatrixMul(int n, const float *a, const float *b, float *result)
}
// Calculate sum of a float list
float MathFloatVectorSum(std::vector<float> Vec)
float MathFloatVectorSum(const std::vector<float>& Vec)
{
float Sum = 0.0;
for(unsigned i = 0; i < Vec.size(); i++)
{
Sum += Vec.at(i);
}
return Sum;
return std::accumulate(Vec.begin(), Vec.end(), 0.0f);
}
void Matrix33::LoadIdentity(Matrix33 &mtx)

View File

@ -151,7 +151,7 @@ inline double pow2(double x) {return x * x;}
void SaveSSEState();
void LoadSSEState();
void LoadDefaultSSEState();
float MathFloatVectorSum(std::vector<float>);
float MathFloatVectorSum(const std::vector<float>&);
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))