SCM

SCM Repository

[bigmemory] Diff of /pkg/bigalgebra/R/bigalgebra.R
ViewVC logotype

Diff of /pkg/bigalgebra/R/bigalgebra.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 470, Mon Sep 8 14:46:33 2014 UTC revision 471, Tue Nov 25 19:35:57 2014 UTC
# Line 22  Line 22 
22    return( ifelse( class(A) == 'big.matrix', TRUE, FALSE ) )    return( ifelse( class(A) == 'big.matrix', TRUE, FALSE ) )
23  }  }
24    
 # Do I need a function to add a scalar to each element of a matrix?  
   
25  # Copy a matrix  # Copy a matrix
26  # Y := X  # Y := X
27  dcopy = function(N=NULL, X, INCX=1, Y, INCY=1)  dcopy = function(N=NULL, X, INCX=1, Y, INCY=1)
# Line 39  Line 37 
37    return(0)    return(0)
38  }  }
39    
40  # Multiply by a scalar  # Add a scalar to each element of a matrix
41  # Y := ALPHA * Y  # Y := Y+SIGN*ALPHA
42  dscal = function(N=NULL, ALPHA, Y, INCY=1)  dadd = function(Y, ALPHA, SIGN=1, ALPHA_LHS=1)
43  {  {
44      if (!is.numeric(ALPHA) || length(ALPHA) != 1)
45        stop("ALPHA is not a scalar numeric value")
46    Y.is.bm = check_matrix(Y)    Y.is.bm = check_matrix(Y)
47    if (is.null(N))    if (Y.is.bm) {
48    {      ret = deepcopy(Y, backingfile="")
49      N = as.double(nrow(Y))*as.double(ncol(Y))    } else {
50        ret = Y
51    }    }
52    .Call('dscal_wrapper', N, as.double(ALPHA), Y, as.double(INCY), Y.is.bm)    N = as.double(nrow(Y)) * as.double(ncol(Y))
53    return(0)    .Call('dadd', N, as.double(ALPHA), ret, Y.is.bm, as.double(SIGN),
54            as.integer(ALPHA_LHS))
55      return(ret)
56  }  }
57    
58  # Add two matrices.  # Add two matrices.

Legend:
Removed from v.470  
changed lines
  Added in v.471

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge