diff options
author | lukyan <lukyan@yandex-team.ru> | 2022-02-10 16:48:13 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:13 +0300 |
commit | 3e359c7e6344b01b8d0b0fc619297ffdc2644c49 (patch) | |
tree | 84fef6ce6ee76479e37582b357af732385cffdcf /library/cpp/linear_regression | |
parent | a02ea31d51f94b7edb98c6ab1322bf26ca04beb5 (diff) | |
download | ydb-3e359c7e6344b01b8d0b0fc619297ffdc2644c49.tar.gz |
Restoring authorship annotation for <lukyan@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/linear_regression')
-rw-r--r-- | library/cpp/linear_regression/linear_regression.cpp | 42 | ||||
-rw-r--r-- | library/cpp/linear_regression/linear_regression.h | 4 |
2 files changed, 23 insertions, 23 deletions
diff --git a/library/cpp/linear_regression/linear_regression.cpp b/library/cpp/linear_regression/linear_regression.cpp index 150f9d214e..bcab777133 100644 --- a/library/cpp/linear_regression/linear_regression.cpp +++ b/library/cpp/linear_regression/linear_regression.cpp @@ -33,7 +33,7 @@ bool TFastLinearRegressionSolver::Add(const TVector<double>& features, const dou AddFeaturesProduct(weight, features, LinearizedOLSMatrix); const double weightedGoal = goal * weight; - double* olsVectorElement = OLSVector.data(); + double* olsVectorElement = OLSVector.data(); for (const double feature : features) { *olsVectorElement += feature * weightedGoal; ++olsVectorElement; @@ -72,31 +72,31 @@ bool TLinearRegressionSolver::Add(const TVector<double>& features, const double ; } - double* olsMatrixElement = LinearizedOLSMatrix.data(); + double* olsMatrixElement = LinearizedOLSMatrix.data(); - const double* lastMean = LastMeans.data(); - const double* newMean = NewMeans.data(); - const double* lastMeansEnd = lastMean + LastMeans.size(); - const double* newMeansEnd = newMean + NewMeans.size(); + const double* lastMean = LastMeans.data(); + const double* newMean = NewMeans.data(); + const double* lastMeansEnd = lastMean + LastMeans.size(); + const double* newMeansEnd = newMean + NewMeans.size(); #ifdef _sse2_ - for (; lastMean != lastMeansEnd; ++lastMean, ++newMean) { + for (; lastMean != lastMeansEnd; ++lastMean, ++newMean) { __m128d factor = _mm_set_pd(*lastMean, *lastMean); const double* secondFeatureMean = newMean; - for (; secondFeatureMean + 1 < newMeansEnd; secondFeatureMean += 2, olsMatrixElement += 2) { + for (; secondFeatureMean + 1 < newMeansEnd; secondFeatureMean += 2, olsMatrixElement += 2) { __m128d matrixElem = _mm_loadu_pd(olsMatrixElement); __m128d secondFeatureMeanElem = _mm_loadu_pd(secondFeatureMean); __m128d product = _mm_mul_pd(factor, secondFeatureMeanElem); __m128d addition = _mm_add_pd(matrixElem, product); _mm_storeu_pd(olsMatrixElement, addition); } - for (; secondFeatureMean < newMeansEnd; ++secondFeatureMean) { + for (; secondFeatureMean < newMeansEnd; ++secondFeatureMean) { *olsMatrixElement++ += *lastMean * *secondFeatureMean; } } #else - for (; lastMean != lastMeansEnd; ++lastMean, ++newMean) { - for (const double* secondFeatureMean = newMean; secondFeatureMean < newMeansEnd; ++secondFeatureMean) { + for (; lastMean != lastMeansEnd; ++lastMean, ++newMean) { + for (const double* secondFeatureMean = newMean; secondFeatureMean < newMeansEnd; ++secondFeatureMean) { *olsMatrixElement++ += *lastMean * *secondFeatureMean; } } @@ -326,13 +326,13 @@ namespace { #ifdef _sse2_ inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedOLSTriangleMatrix) { - const double* leftFeature = features.data(); - const double* featuresEnd = features.data() + features.size(); - double* matrixElement = linearizedOLSTriangleMatrix.data(); + const double* leftFeature = features.data(); + const double* featuresEnd = features.data() + features.size(); + double* matrixElement = linearizedOLSTriangleMatrix.data(); size_t unaligned = features.size() & 0x1; - for (; leftFeature != featuresEnd; ++leftFeature, ++matrixElement) { + for (; leftFeature != featuresEnd; ++leftFeature, ++matrixElement) { const double weightedFeature = weight * *leftFeature; const double* rightFeature = leftFeature; __m128d wf = {weightedFeature, weightedFeature}; @@ -340,7 +340,7 @@ namespace { *matrixElement += weightedFeature * *rightFeature; } unaligned = (unaligned + 1) & 0x1; - for (; rightFeature != featuresEnd; rightFeature += 2, matrixElement += 2) { + for (; rightFeature != featuresEnd; rightFeature += 2, matrixElement += 2) { __m128d rf = _mm_loadu_pd(rightFeature); __m128d matrixRow = _mm_loadu_pd(matrixElement); __m128d rowAdd = _mm_mul_pd(rf, wf); @@ -352,13 +352,13 @@ namespace { } #else inline void AddFeaturesProduct(const double weight, const TVector<double>& features, TVector<double>& linearizedTriangleMatrix) { - const double* leftFeature = features.data(); - const double* featuresEnd = features.data() + features.size(); - double* matrixElement = linearizedTriangleMatrix.data(); - for (; leftFeature != featuresEnd; ++leftFeature, ++matrixElement) { + const double* leftFeature = features.data(); + const double* featuresEnd = features.data() + features.size(); + double* matrixElement = linearizedTriangleMatrix.data(); + for (; leftFeature != featuresEnd; ++leftFeature, ++matrixElement) { const double weightedFeature = weight * *leftFeature; const double* rightFeature = leftFeature; - for (; rightFeature != featuresEnd; ++rightFeature, ++matrixElement) { + for (; rightFeature != featuresEnd; ++rightFeature, ++matrixElement) { *matrixElement += weightedFeature * *rightFeature; } *matrixElement += weightedFeature; diff --git a/library/cpp/linear_regression/linear_regression.h b/library/cpp/linear_regression/linear_regression.h index e57de5ff6c..5015e2e4b6 100644 --- a/library/cpp/linear_regression/linear_regression.h +++ b/library/cpp/linear_regression/linear_regression.h @@ -147,12 +147,12 @@ public: bool Add(const TVector<double>& features, const TVector<double>& goals) { Y_ASSERT(features.size() == goals.size()); - return Add(features.data(), features.data() + features.size(), goals.data()); + return Add(features.data(), features.data() + features.size(), goals.data()); } bool Add(const TVector<double>& features, const TVector<double>& goals, const TVector<double>& weights) { Y_ASSERT(features.size() == goals.size() && features.size() == weights.size()); - return Add(features.data(), features.data() + features.size(), goals.data(), weights.data()); + return Add(features.data(), features.data() + features.size(), goals.data(), weights.data()); } template <typename TFloatType> |