RobinHankin / stokes

methods for exterior calculus
https://robinhankin.github.io/stokes/
3 stars 0 forks source link

Give Alt() the option to return a k-form #46

Closed RobinHankin closed 3 years ago

RobinHankin commented 3 years ago

Currently, given a k-tensor, function Alt() returns another k-tensor which is guaranteed to be alternating. It would be nice for Alt() to take an argument to return a k-form instead. Look:

> V <- matrix(rnorm(12),ncol=3)
> KF <- as.kform(cbind(2,4,1),1)
> KT <- Alt(as.ktensor(cbind(2,4,1),6))
> 
> 
> as.function(KF)(V)
[1] 0.4470976
> as.function(KT)(V)
[1] 0.4470976
> 

In the above, it is clear that objects KT and KF are identical functions, but currently there is no nice package idiom to convert KT to KF. Maybe adding argument give_kform to Alt() would be good.

RobinHankin commented 3 years ago

Note that function kform() can take a k-tensor, but:

> a <- as.ktensor(matrix(c(1,2,7,1,6,4,1,1,4,3,3,3),byrow=T,ncol=3),1:4)
> a
A linear map from V^3 to R with V=R^7:
           val
 3 3 3  =    4
 1 1 4  =    3
 1 6 4  =    2
 1 2 7  =    1
> as.function(Alt(a))(V)
[1] -0.2330575
> as.function(kform(a))(V)/6
[1] -0.2330575
> 

Everything is working as intended but what we need is for Alt(a,give_kform=TRUE) to return kform(Alt(a))/6