RcppQRHdf5_dispatch

C++ Function Reference

1 Signature

void BigDataStatMeth::RcppQRHdf5_dispatch(BigDataStatMeth::hdf5Dataset *dsA, BigDataStatMeth::hdf5Dataset *dsQ, BigDataStatMeth::hdf5Dataset *dsR, bool bthin, Rcpp::Nullable< int > block_size, Rcpp::Nullable< int > threads, const std::string &method)

2 Description

Unified QR entry point — dispatches to LAPACK or TSQR based on method.

3 Parameters

  • dsA (BigDataStatMeth::hdf5Dataset *): Input matrix dataset
  • dsQ (BigDataStatMeth::hdf5Dataset *): Output Q matrix dataset
  • dsR (BigDataStatMeth::hdf5Dataset *): Output R matrix dataset
  • bthin (bool): Thin (true) or full (false) QR
  • block_size (Rcpp::Nullable< int >): Block size hint (NULL = auto)
  • threads (Rcpp::Nullable< int >): Thread count (NULL = auto)
  • method (const std::string &): “auto”, “lapack”, or “tsqr”

4 Details

Wrapper that selects the appropriate QR algorithm:“lapack” : Eigen HouseholderQR (existing implementation)“tsqr” : Parallel TSQR (new, efficient for tall-skinny)“auto” : TSQR if m > 5*n AND m > 1000, otherwise LAPACK

5 Call Graph

Function dependencies

6 Source Code

File: inst/include/hdf5Algebra/matrixQR.hppLines 649-681

inline void RcppQRHdf5_dispatch( BigDataStatMeth::hdf5Dataset* dsA,
                                  BigDataStatMeth::hdf5Dataset* dsQ,
                                  BigDataStatMeth::hdf5Dataset* dsR,
                                  bool bthin,
                                  Rcpp::Nullable<int> block_size,
                                  Rcpp::Nullable<int> threads,
                                  const std::string& method )
{
    // R dimensions (corrected for HDF5 transposition)
    const int m = static_cast<int>(dsA->ncols());   // R rows
    const int n = static_cast<int>(dsA->nrows());   // R cols

    // Resolve effective method
    std::string eff_method = method;
    if (eff_method == "auto") {
        // TSQR is beneficial for tall-skinny matrices and when matrix is large
        // enough to amortise the parallel overhead
        eff_method = (m > 5 * n && m > 1000) ? "tsqr" : "lapack";
    }

    if (eff_method == "tsqr") {
        if (m < n)
            throw std::runtime_error(
                "method='tsqr' requires m >= n; use method='lapack' for wide matrices");
        RcppTSQRHdf5(dsA, dsQ, dsR, bthin, block_size, threads);
    } else if (eff_method == "lapack") {
        RcppQRHdf5(dsA, dsQ, dsR, bthin, block_size, threads);
    } else {
        throw std::runtime_error(
            std::string("RcppQRHdf5_dispatch: unknown method '") + eff_method +
            "'. Use 'auto', 'lapack', or 'tsqr'.");
    }
}

7 Usage Example

#include "BigDataStatMeth.hpp"

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