Learn R Programming

capn (version 1.0.0)

unigrids: Generating unifrom grids

Description

This function generates a grid of multi-dimensional uniform grids.

Usage

unigrids(nnodes, lb, ub, rtype = NULL)

Arguments

nnodes

An array of numbers of nodes

lb

An array of lower bounds

ub

An array of upper bounds

rtype

A type of results; default is NULL that returns a list class; if rtype = list, returns a list class; if rtype = grid, returns a matrix class.

Value

A list with \(d\) elements of Chebyshev nodes or a \( \left( \displaystyle \prod_{i=1}^{d} n_{i} \right) \times d\) matrix of uniform grids

Details

For the \(i\)-th dimension of \(i = 1, 2, \cdots, d\), suppose a polynomial approximant \(s_{i}\) over a bounded interval \([a_{i},b_{i}]\) is defined by evenly gridded nodes. Then, a \(d\)-dimensional uniform grids can be defined as:

\(\mathbf{S} = \left\{ (s_{1},s_{2},\cdots,s_{d}) \vert a_{i} \leq s_{1} \leq b_{i}, i = 1, 2, \cdots, d \right\} \).

This is all combinations of \(s_{i}\). Two types of results are provided. 'rtype = list' provides a list of \(d\) dimensions wherease 'rtype = grids' creates a \( \left( \displaystyle \prod_{i=1}^{d} n_{i} \right) \times d\) matrix.

Examples

Run this code
## Uniform grids with two-dimension
unigrids(c(5,3), c(1,1), c(2,3))
## Returns the same results
unigrids(c(5,3), c(1,1), c(2,3), rtype='list')
## Returns a matrix grids with the same domain
unigrids(c(5,3), c(1,1), c(2,3), rtype='grid')
## Uniform grid with one-dimension
unigrids(5,1,2)
## Uniform grids with three stock
unigrids(c(3,4,5),c(1,1,1),c(2,3,4),rtype='grid')

Run the code above in your browser using DataLab