R/ComplexMethods_tensorflow.R

setMethod("Complex",
          c(z="gpu.matrix.tensorflow"),
          function(z)
          {
            op = .Generic[[1]]
            switch(op,
                   'Re' = {
                     z@gm <- tensorflow::tf$math$real(z@gm)
                   },
                   'Im' = {
                     z@gm <- tensorflow::tf$math$imag(z@gm)
                   },
                   'Conj' = {
                     z@gm <- tensorflow::tf$math$conj(z@gm)
                   },
                   'Arg' = {
                     z@gm <- tensorflow::tf$math$angle(z@gm)
                   },
                   'Mod'={
                     z@gm <- tensorflow::tf$math$abs(z@gm)
                   }
            )
            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.