R/ComplexMethods_torch.R

setMethod("Complex",
          c(z="gpu.matrix.torch"),
          function(z)
          {
            op = .Generic[[1]]
            switch(op,
                   'Re' = {
                     z@gm <- z@gm$real
                   },
                   'Im' = {
                     z@gm <- z@gm$imag
                   },
                   'Conj' = {
                     z@gm <- z@gm$conj()
                   },
                   'Arg' = {
                     z@gm <- z@gm$angle()
                   },
                   'Mod'={
                     z@gm <- z@gm$abs()
                   }
            )
            return(z)
          }
)

Try the GPUmatrix package in your browser

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

GPUmatrix documentation built on May 29, 2024, 11:02 a.m.