mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 04:55:43 +01:00
Built-in rand was causing severe perf issues.
This commit is contained in:
parent
675ebc28a1
commit
037cb0951b
@ -50,16 +50,14 @@ namespace FasTC {
|
||||
// Returns them in eigVec and eigVal after kMaxNumIterations
|
||||
int PowerMethod(VectorBase<T, N> &eigVec,
|
||||
T *eigVal = NULL,
|
||||
const int kMaxNumIterations = 200,
|
||||
const unsigned int kSeed = time(NULL)) {
|
||||
const int kMaxNumIterations = 5) {
|
||||
|
||||
srand(kSeed);
|
||||
int numIterations = 0;
|
||||
|
||||
VectorBase<T, N> b;
|
||||
T norm = 1.0/sqrt(static_cast<T>(N));
|
||||
for(int i = 0; i < N; i++)
|
||||
b[i] = static_cast<T>(rand());
|
||||
b.Normalize();
|
||||
b[i] = norm;
|
||||
|
||||
bool badEigenValue = false;
|
||||
bool fixed = false;
|
||||
@ -82,8 +80,8 @@ namespace FasTC {
|
||||
}
|
||||
|
||||
VectorBase<T, N> b;
|
||||
for(int i = 0; i < N; i++)
|
||||
b[i] = static_cast<T>(rand());
|
||||
for(int i = 0; i < (N>>1); i++)
|
||||
b[i] = 1;
|
||||
|
||||
b.Normalize();
|
||||
badEigenValue = true;
|
||||
|
@ -252,7 +252,7 @@ TEST(MatrixSquare, PowerMethod) {
|
||||
|
||||
double e;
|
||||
FasTC::VectorBase<double, 2> x;
|
||||
A.PowerMethod(x, &e, 20, 200);
|
||||
A.PowerMethod(x, &e, 20);
|
||||
|
||||
EXPECT_NEAR(x[0], 0.83205f, 0.0002);
|
||||
EXPECT_NEAR(x[1], 0.5547f, 0.0002);
|
||||
|
Loading…
Reference in New Issue
Block a user