Giter Club home page Giter Club logo

tensorpolynomialbases.jl-f77b161d-e03a-5d68-b365-d5306aabeaa6's Introduction

TensorPolynomialBases

Build Status Codecov

The TensorPolynomialBases package provides a collection of different types representing tensor-valued multivariate polynomial bases. It provides a common interface, called TensorPolynomialBasis, and several concrete implementations. At the moment, only a concrete implementation, called MonomialBasis is available, which implements a tensor-valued multivariate monomial basis. For representing the tensor values arising in the evaluation of tensor-valued polynomails, the user can either use the StaticArrays or the TensorValues packages.

Quick start

Create a vector-valued monomial basis of P-polynomials in 2 variables

using TensorPolynomialBases
using StaticArrays

# Define a filter to select the monomials in the P-space
filter(e,order) = sum(e) <= order

order= 4
P = SVector{2,Float64} # type of the evaluation point
V = SVector{3,Float64} # type of the value

basis = MonomialBasis{P,V}(filter,order)

# Create scratch data that can be reused between evaluations
cache = ScratchData(basis)

# Evaluation point
x = @SVector rand(3)

# Evaluation
v = zeros(V,length(basis))
evaluate!(v,basis,x,cache) # No memory allocation here
@show v

# Evaluation of the gradient
G = gradient_type(basis)
# G == SMatrix{2,3,T,6}
v = zeros(G,length(basis))
gradient!(v,basis,x,cache) # No memory allocation here
@show v

Create a Tensor-valued monomial basis of the "serendipity" space in 3 variables (this time using the types of the TensorValues package)

using TensorValues

# Define the filter for the serendipity space
filter(e,order) = sum( ( i for i in e if i>1 ) ) <= order

order= 3
P = VectorValue{3,Float64} # type of the evaluation point
V = TensorValue{3,Float64,9} # type of the value (3x3 tensor)

basis = MonomialBasis{P,V}(filter,order)

# Create scratch data that can be reused between evaluations
cache = ScratchData(basis)

# Evaluation point
x = VectorValue(0.1,2.0,3.1)

# Evaluation
v = zeros(V,length(basis))
evaluate!(v,basis,x,cache) # No memory allocation here
@show v

tensorpolynomialbases.jl-f77b161d-e03a-5d68-b365-d5306aabeaa6's People

Contributors

fverdugo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.