Skip to content

No variants for R matrix slicing #20

@mynanshan

Description

@mynanshan

I found that one has to manually complete all the indexes for matrix slicing. Example:

library(autodiffr)

f <- function(x){
  y <- array(c(x,x), dim = c(length(x), 2))
  return(sum(y[,1]))
}

ad_grad(f, c(1,1))
#> Julia version 1.7.0 at location D:\Software\Julia-1.7.0\bin will be used.
#> Loading setup script for JuliaCall...
#> Finish loading setup script for JuliaCall.
#> Loading ReverseDiff...
#> Loading ForwardDiff...
#> Finish autodiffr setup.
#> Error: Error happens in Julia.
#> REvalError:

f <- function(x){
  y <- array(c(x,x), dim = c(length(x), 2))
  return(sum(y[1:2,1]))
}

ad_grad(f, c(1,1))
#> [1] 1 1

Created on 2022-04-09 by the reprex package (v2.0.1)

My environment and package versions:

R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

other attached packages:
[1] autodiffr_0.1.0.9000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions