multiplyDiagonals

C++ Function Reference

1 Signature

void BigDataStatMeth::DiagonalOps::multiplyDiagonals(BigDataStatMeth::hdf5Dataset *dsA, BigDataStatMeth::hdf5Dataset *dsB, BigDataStatMeth::hdf5Dataset *dsResult, std::string target="new", bool bparal=false, Rcpp::Nullable< int > threads=R_NilValue)

2 Description

Multiply diagonal elements from two matrices or vectors.

3 Parameters

  • dsA (BigDataStatMeth::hdf5Dataset *): First input dataset
  • dsB (BigDataStatMeth::hdf5Dataset *): Second input dataset
  • dsResult (BigDataStatMeth::hdf5Dataset *): Result dataset (will be created)
  • target (std::string): Where to write result: “A”, “B”, or “new”
  • bparal (bool): Whether to use parallel processing
  • threads (Rcpp::Nullable< int >): Number of threads for parallel processing

4 Details

Performs optimized diagonal multiplication C_diag = A_diag * B_diag. Same optimization strategy as addDiagonals but for element-wise multiplication.

5 Call Graph

Function dependencies

6 Source Code

File: inst/include/hdf5Utilities/hdf5DiagonalMethods.hppLines 469-488

inline void multiplyDiagonals(BigDataStatMeth::hdf5Dataset* dsA, BigDataStatMeth::hdf5Dataset* dsB,
                                      BigDataStatMeth::hdf5Dataset* dsResult, std::string target = "new",
                                      bool bparal = false, Rcpp::Nullable<int> threads = R_NilValue)
        {
            try {
                bool isVectorA = isDiagonalVector(dsA);
                bool isVectorB = isDiagonalVector(dsB);
                
                if (isVectorA && isVectorB && (target == "A" || target == "B")) {
                    BigDataStatMeth::hdf5Dataset* targetDataset = (target == "A") ? dsA : dsB;
                    Rcpp_vector_multiply_hdf5(dsA, dsB, targetDataset, bparal, threads);
                } else if (isVectorA && isVectorB && target == "new") {
                    Rcpp_vector_multiply_hdf5(dsA, dsB, dsResult, bparal, threads);
                } else {
                    performMatrixDiagonalOperation(dsA, dsB, dsResult, 2, target, bparal, threads);
                }
            } catch(std::exception& ex) {
                Rf_error("Error in multiplyDiagonals: %s", ex.what());
            }
        }

7 Usage Example

#include "BigDataStatMeth.hpp"

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