interpolMatrix: Interpolate matrix

View source: R/math.R

interpolMatrixR Documentation

Interpolate matrix

Description

Internal soundgen function

Usage

interpolMatrix(m, nr = NULL, nc = NULL, interpol = c("approx", "spline")[1])

Arguments

m

input matrix of numeric values

nr, nc

target dimensions

interpol

interpolation method ('approx' for linear, 'spline' for spline)

Details

Performs a chosen type of interpolation (linear or smooth) across both rows and columns of a matrix, in effect up- or downsampling a matrix to required dimensions. Rownames and colnames are also interpolated as needed.

Examples

m = matrix(1:12 + rnorm(12, 0, .2), nrow = 3)
rownames(m) = 1:3; colnames(m) = 1:4
soundgen:::interpolMatrix(m)  # just returns the original
soundgen:::interpolMatrix(m, nr = 10, nc = 7)
soundgen:::interpolMatrix(m, nr = 10, nc = 7, interpol = 'spline')
soundgen:::interpolMatrix(m, nr = 2, nc = 7)
soundgen:::interpolMatrix(m, nr = 2, nc = 3)

# input matrices can have a single row/column
soundgen:::interpolMatrix(matrix(1:5, nrow = 1), nc = 9)
soundgen:::interpolMatrix(matrix(1:5, ncol = 1), nr = 5, nc = 3)

soundgen documentation built on Sept. 12, 2024, 6:29 a.m.