xtwx

C++ Function Reference

1 Signature

Eigen::MatrixXd BigDataStatMeth::xtwx(const Eigen::MatrixXd &X, const Eigen::MatrixXd &w)

2 Description

Compute transposed weighted cross-product X’wX.

3 Parameters

  • X (const Eigen::MatrixXd &): Input matrix
  • w (const Eigen::MatrixXd &): Weight matrix

4 Returns

Transposed weighted cross-product X’wX

5 Details

Computes the transposed weighted cross-product of a matrix, where w is a diagonal weight matrix.

6 Source Code

File: inst/include/memAlgebra/memOptimizedProducts.hppLines 222-228

inline Eigen::MatrixXd xtwx(const Eigen::MatrixXd& X, const Eigen::MatrixXd& w)
{
    const int n(X.cols());
    Eigen::MatrixXd XtwX(Eigen::MatrixXd(n, n).setZero().
                             selfadjointView<Eigen::Lower>().rankUpdate(X.adjoint() * w.array().sqrt().matrix().asDiagonal()));
    return (XtwX);
}

7 Usage Example

#include "BigDataStatMeth.hpp"

// Example usage
auto result = xtwx(...);