-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
391 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
conv2D_f0 <- function(a, b) { | ||
require(dotCall64) | ||
dyn.load("AquaFortR_Codes/conv2D.so") | ||
|
||
|
||
m <- nrow(a) | ||
n <- ncol(b) | ||
|
||
p <- nrow(b) | ||
q <- ncol(b) | ||
# the full convolution matrix | ||
conv_row <- nrow(a) + nrow(b) - 1 | ||
conv_col <- ncol(a) + ncol(b) - 1 | ||
conv <- matrix(1:c(conv_row * conv_col), | ||
byrow = FALSE, ncol = conv_col | ||
) | ||
|
||
result <- .Fortran("conv2d_f", | ||
m = as.integer(dim(a)[1]), | ||
n = as.integer(dim(a)[2]), | ||
p = as.integer(dim(b)[1]), | ||
q = as.integer(dim(b)[2]), | ||
k = as.integer(conv_row), | ||
l = as.integer(conv_col), | ||
a = as.double(a), | ||
b = as.double(b), | ||
conv = as.double(conv) | ||
)$conv | ||
|
||
return(matrix(result, nrow = conv_row, ncol = conv_col)) | ||
} | ||
conv_row <- m + p - 1 | ||
conv_col <- n + q - 1 | ||
conv <- matrix(0, | ||
ncol = conv_col, | ||
nrow = conv_row) | ||
|
||
conv <- .C64("conv2d_f", | ||
SIGNATURE = c(rep("integer",6), | ||
rep("double",3)), | ||
INTENT = c(rep("r",8), "rw"), | ||
m, n, p, q, | ||
k = conv_row, | ||
l = conv_col, | ||
a = a, b = b, | ||
conv = conv)$conv | ||
|
||
return(conv) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Further Reading | ||
* [Fortran and R – Speed Things Up](https://www.r-bloggers.com/2014/04/fortran-and-r-speed-things-up/) by Steve Pittard | ||
* [The Need for Speed Part 1: Building an R Package with Fortran (or C)](https://www.r-bloggers.com/2018/12/the-need-for-speed-part-1-building-an-r-package-with-fortran-or-c/) by Avraham Adler | ||
* [The Need for Speed Part 2: C++ vs. Fortran vs. C](https://www.avrahamadler.com/2018/12/23/the-need-for-speed-part-2-c-vs-fortran-vs-c/) by Avraham Adler | ||
* [Writing R Extensions](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Writing-R-Extensions) by R Core Team | ||
* [Modern Fortran Tutorial](https://masuday.github.io/fortran_tutorial/index.html) by Yutaka Masuda | ||
* [Extend R with Fortran](https://masuday.github.io/fortran_tutorial/r.html) by Yutaka Masuda | ||
* [Advanced R](http://adv-r.had.co.nz/) by Hadley Wickham | ||
* [Fortran 90 Tutorial](http://web.stanford.edu/class/me200c/tutorial_90/) by Stanford University | ||
* [Fortran Libraries](https://fortranwiki.org/fortran/show/Libraries) by Fortran Wiki | ||
* [Fortran Best Practices](https://fortran-lang.org/en/learn/best_practices/#fortran-best-practices) by Fortran Community | ||
* [Fortran 90 Reference Card](https://web.pa.msu.edu/people/duxbury/courses/phy480/fortran90_refcard.pdf) by Michael Goerz. | ||
* [Hands-On Programming with R](https://rstudio-education.github.io/hopr/) by Garrett Grolemund | ||
* [r-spatial](https://r-spatial.org/) by Edzer Pebesma, Marius Appel, and Daniel Nüst | ||
* [Spatial Data Science](https://rspatial.org/index.html) | ||
* [R for Data Science (2e)](https://r4ds.hadley.nz/) by Hadley Wickham, Mine Çetinkaya-Rundel, and Garrett Grolemund | ||
* [Introduction to Environmental Data Science](https://bookdown.org/igisc/EnvDataSci/) by Jerry Davis | ||
|
||
<!-- https://cran.r-project.org/doc/manuals/r-release/R-exts.html#System-and-foreign-language-interfaces-1 --> | ||
|
||
<!-- Fortran is primarily intended for Fortran 77 code, and long precedes any support for Fortran 9x. Now current implementations of Fortran 9x support the Fortran 2003 module iso_c_binding, a better way to interface modern Fortran code to R is to use .C and write a C interface using use iso_c_binding. --> | ||
|
||
<!-- The header files R_ext/BLAS.h, R_ext/Lapack.h and R_ext/Linpack.h contains declarations of the BLAS, LAPACK and LINPACK linear algebra functions included in R. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.