R/base_pblas_level3.r

Defines functions base.rpdtran base.rpdgemm

Documented in base.rpdgemm base.rpdtran

# ------------------------------------------------
# PDTRAN:  Matrix transpose
# ------------------------------------------------

#' rpdtran
#' 
#' Transpose.
#' 
#' For advanced users only. See pbdDMAT for high-level functions.
#' 
#' @param a
#' Matrix.
#' @param desca,descc
#' ScaLAPACK descriptor array.
#' 
#' @useDynLib pbdBASE R_PDTRAN
#' @export
base.rpdtran <- function(a, desca, descc)
{
  m <- descc[3L]
  n <- descc[4L]
  
  if (!is.double(a))
    storage.mode(a) <- "double"
  
  cldim <- base.numroc(descc[3L:4L], descc[5L:6L], ICTXT=descc[2L])
  
  ret <- .Call(R_PDTRAN,
                as.integer(m), as.integer(n),
                a, as.integer(desca),
                as.integer(cldim), as.integer(descc))
  
  ret
}

# ------------------------------------------------
# PDGEMM:  Matrix-Matrix multiplication
# ------------------------------------------------

#' rpdgemm
#' 
#' Matrix-Matrix Multiply.
#' 
#' For advanced users only. See pbdDMAT for high-level functions.
#' 
#' @param transx,transy
#' 'T' or 'N' for transpose or not.
#' @param x,y
#' Matrix.
#' @param descx,descy,descc
#' ScaLAPACK descriptor array.
#' 
#' @useDynLib pbdBASE R_PDGEMM
#' @export
base.rpdgemm <- function(transx, transy, x, descx, y, descy, descc)
{
  transx <- toupper(transx)
  transy <- toupper(transy)
  
  if (transx == 'N')
    m <- descx[3L]
  else
    m <- descx[4L]
  
  if (transy == 'N')
  {
    n <- descy[4L]
    k <- descy[3L]
  }
  else
  {
    n <- descy[3L]
    k <- descy[4L]
  }
    
  cldim <- base.numroc(descc[3:4], descc[5:6], ICTXT=descc[2])
  
  if (!is.double(x))
    storage.mode(x) <- "double"
  if (!is.double(y))
    storage.mode(y) <- "double"
  
  ret <- .Call(R_PDGEMM, transx, transy,
    as.integer(m), as.integer(n), as.integer(k),
    x, as.integer(descx),
    y, as.integer(descy),
    as.integer(cldim), as.integer(descc))
  
  ret
}

Try the pbdBASE package in your browser

Any scripts or data that you put into this service are public.

pbdBASE documentation built on March 26, 2020, 9:37 p.m.