forked from functionaldata/tPACE
-
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.
Fixing (partially) the zero weights issue in 1-D and moving all lwls1…
…d to Rlwls1d. locfit dependancy dropped.
- Loading branch information
1 parent
b4bdbe0
commit 00aa715
Showing
5 changed files
with
82 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file was generated by Rcpp::compileAttributes | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
dropZeroElementsXYWin <- function(win, xin, yin) { | ||
.Call('tPACE_dropZeroElementsXYWin', PACKAGE = 'tPACE', win, xin, yin) | ||
} | ||
|
||
interp2lin <- function(xin, yin, zin, xou, you) { | ||
.Call('tPACE_interp2lin', PACKAGE = 'tPACE', xin, yin, zin, xou, you) | ||
} | ||
|
||
Rlwls1d <- function(bw, kernel_type, win, xin, yin, xout, npoly = 1L, nder = 0L) { | ||
.Call('tPACE_Rlwls1d', PACKAGE = 'tPACE', bw, kernel_type, win, xin, yin, xout, npoly, nder) | ||
} | ||
|
||
Rmullwlsk <- function(bw, kernel_type, tPairs, cxxn, win, xgrid, ygrid, bwCheck) { | ||
.Call('tPACE_Rmullwlsk', PACKAGE = 'tPACE', bw, kernel_type, tPairs, cxxn, win, xgrid, ygrid, bwCheck) | ||
} | ||
|
||
Rrotatedmullwlsk <- function(bw, kernel_type, tPairs, cxxn, win, xygrid, npoly, bwCheck) { | ||
.Call('tPACE_Rrotatedmullwlsk', PACKAGE = 'tPACE', bw, kernel_type, tPairs, cxxn, win, xygrid, npoly, bwCheck) | ||
} | ||
|
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
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,48 @@ | ||
#include <RcppEigen.h> | ||
#include <map> // to map kernels to integers for the switch | ||
#include <string> // to read in the kernel name | ||
#include <vector> // to use vectors | ||
#include <algorithm> // to get the intersect and sort | ||
|
||
// [[Rcpp::depends(RcppEigen)]] | ||
// [[Rcpp::export]] | ||
|
||
|
||
Eigen::MatrixXd dropZeroElementsXYWin( const Eigen::Map<Eigen::VectorXd> & win, const Eigen::Map<Eigen::VectorXd> & xin, const Eigen::Map<Eigen::VectorXd> & yin){ | ||
|
||
const unsigned int nXGrid = xin.size(); | ||
|
||
// Check that we have equal number of readings | ||
if( nXGrid != yin.size()){ | ||
Rcpp::stop("The input Y-grid does not have the same number of points as input X-grid."); | ||
} | ||
|
||
if( nXGrid != win.size()){ | ||
Rcpp::stop("The input weight vector does not have the same number of points as input X-grid."); | ||
} | ||
|
||
unsigned int nZeroElements = std::count(&win[0], &win[nXGrid], 0.); | ||
|
||
Eigen::MatrixXd Q(nZeroElements,3); | ||
|
||
// Check that we do not have zero weights // Should do a try-catch here | ||
if( nZeroElements != 0 ){ // | ||
Eigen::MatrixXd Q(nXGrid - nZeroElements,3); | ||
unsigned int q = 0; | ||
for( unsigned int i = 0; i != nXGrid; ++i){ | ||
if ( win[i] != 0 ) { | ||
Q(q,0) = xin[i]; | ||
Q(q,1) = yin[i]; | ||
Q(q,2) = win[i]; | ||
++q; | ||
} | ||
} | ||
return( Q ); | ||
} else { | ||
Eigen::MatrixXd Q(nXGrid,3); | ||
Q.col(0) = xin; | ||
Q.col(1) = yin; | ||
Q.col(2) = win; | ||
return( Q ); | ||
} | ||
} |