R/LogicMethod_torch.R

setMethod("Logic",
          c(e1="gpu.matrix.torch", e2="ANY"),
          function(e1, e2)
          {
            op = .Generic[[1]]
            castMatrix <- castTypeOperations_torch(e1,e2)
            e1 <- castMatrix[[1]]
            e2 <- castMatrix[[2]]
            dtype(e2) <- "bool"
            dtype(e2) <- "bool"

            switch(op,
                   '&' = {
                     return(gpu.matrix.torch(e1@gm&e2@gm))
                   },
                   '|' = {
                     return(gpu.matrix.torch(e1@gm|e2@gm))
                   }
            )
          }
)

setMethod("Logic",
          c(e1="ANY", e2="gpu.matrix.torch"),
          function(e1, e2)
          {
            op = .Generic[[1]]
            castMatrix <- castTypeOperations_torch(e1,e2)
            e1 <- castMatrix[[1]]
            e2 <- castMatrix[[2]]
            dtype(e2) <- "bool"
            dtype(e2) <- "bool"

            switch(op,
                   '&' = {
                     return(gpu.matrix.torch(e1@gm&e2@gm))
                   },
                   '|' = {
                     return(gpu.matrix.torch(e1@gm|e2@gm))
                   }
            )
          }
)

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.