13template <
typename Func,
class T>
27 checkfSlow(x.
Num() == y.Num(),
TEXT(
"LanczosCG: trying to take the dot product with vectors of different size."));
31 result += x[i] * y[i];
39 checkfSlow(x.
Num() == y.
Num(),
TEXT(
"LanczosCG: trying to take a linear combination of vectors with different sizes."));
58 checkfSlow(x.
Num() == y.
Num(),
TEXT(
"LanczosCG: trying to set to vectors with different sizes."));
69template <
class T,
typename Func,
int32 d=3>
81 checkfSlow(x.
Num() == y.Num(),
TEXT(
"Chaos::LanczosCG()::dot_product[]: x and y not sized consistently."));
83 if (use_list !=
nullptr)
87 for (
int32 i = 0; i < use_list->Num(); ++i)
90 int32 j = (*use_list)[i];
91 for (
int32 alpha = 0; alpha < d; alpha++)
93 dot += x[j][alpha] * y[j][alpha];
107 for (
size_t alpha = 0; alpha < d; alpha++)
109 dot += x[i][alpha] * y[i][alpha];
119 checkfSlow(x.
Num() == y.
Num(),
TEXT(
"Chaos::LanczosCG()::AXPY[]: x and y not sized consistently."));
120 if (use_list !=
nullptr)
124 const int32 j = (*use_list)[i];
125 for (int32 alpha = 0; alpha < d; alpha++)
127 y[j][alpha] += a * x[j][alpha];
130 use_list->Num() < 1000);
136 for (int32 alpha = 0; alpha < d; alpha++)
138 y[i][alpha] += a * x[i][alpha];
146 if (use_list !=
nullptr)
150 const int32 j = (*use_list)[i];
151 for (int32 alpha = 0; alpha < d; alpha++)
153 y[j][alpha] = a * y[j][alpha];
161 for (size_t alpha = 0; alpha < d; alpha++)
163 y[i][alpha] = a * y[i][alpha];
170 if (use_list !=
nullptr)
174 const int32 j = (*use_list)[i];
175 for (size_t alpha = 0; alpha < d; alpha++)
177 y[j][alpha] = x[j][alpha];
185 for (int32 alpha = 0; alpha < d; alpha++)
187 y[i][alpha] = x[i][alpha];
196template <
typename T,
typename TV,
typename Func1,
typename Func2,
typename Func3,
typename Func4,
typename Func5>
206 const T
res = T(1e-4),
242 for (
int it = 1; it <
max_it; it++)
260 UE_LOG(
LogChaos, VeryVerbose,
TEXT(
"Lanczos residual = %g. Lanczos converged in %d iterations."),
beta, it);
#define checkfSlow(expr, format,...)
Definition AssertionMacros.h:333
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
Definition SkeletalMeshComponent.h:307
void CHAOS_API PhysicsParallelFor(int32 InNum, TFunctionRef< void(int32)> InCallable, bool bForceSingleThreaded=false)
Definition Parallel.cpp:55
void LanczosCG(Func multiplyA, TArray< T > &x, const TArray< T > &b, const int max_it, const T res=1e-4, bool check_residual=false, int min_parallel_batch_size=1000)
Definition Krylov.h:14
float v
Definition radaudio_mdct.cpp:62