mrc-ide / odin.dust
Showing 1 of 4 files from the diff.
Other files ignored by Codecov
NEWS.md has changed.
DESCRIPTION has changed.

@@ -7,6 +7,10 @@
Loading
7 7
    }
8 8
    args <- x[-1L]
9 9
    n <- length(args)
10 +
11 +
    if (fn == "+") {
12 +
      args <- flatten_addition(args)
13 +
    }
10 14
    values <- vcapply(args, generate_dust_sexp, data, meta, supported, gpu)
11 15
12 16
    if (fn == "(") {
@@ -16,6 +20,8 @@
Loading
16 20
      ret <- sprintf("%s[%s]", values[[1L]], pos)
17 21
    } else if (fn == "^") {
18 22
      ret <- sprintf("std::pow(%s, %s)", values[[1]], values[[2]])
23 +
    } else if (fn == "+") {
24 +
      ret <- paste(values, collapse = " + ")
19 25
    } else if (n == 2L && fn %in% odin:::FUNCTIONS_INFIX) {
20 26
      fmt <- switch(fn,
21 27
                    "/" = "%s %s (real_type) %s",
@@ -114,3 +120,26 @@
Loading
114 120
    sprintf("odin_sum%d<%s>(%s)", length(i), type, arg_str)
115 121
  }
116 122
}
123 +
124 +
125 +
## Especially for the GPU output we create some pretty large strings
126 +
## of additions a + b + c + ... + z, which then causes stack overflow
127 +
## when recursing through the expression.  This helper does a tail
128 +
## call elimination on the expressions, converting
129 +
##     (+ (+ a b) c)
130 +
## to
131 +
##     (+ a b c)
132 +
## so that the subsequent conversion to sexp does not need to recurse
133 +
## deeply. Of course we can't do that with recursion, so doing that
134 +
## here with a while loop.
135 +
flatten_addition <- function(args) {
136 +
  tail <- list(args[[2]])
137 +
  args <- args[[1]]
138 +
  while (is_call(args, "+")) {
139 +
    tail <- c(list(args[[3]]), tail)
140 +
    args <- args[[2]]
141 +
  }
142 +
143 +
  args <- list(args)
144 +
  c(args, tail)
145 +
}
Files Coverage
R 100.00%
Project Totals (7 files) 100.00%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading