TensorsOperations, lookups and functions

is there functionality like TensorOperations that supports functions and named lookups?

I have an array of deals. Each specifies a curve, and needs to be valued over many simulated iterations of the curve. I’d like to write it as:

@tensor result[d,sim] := value.( deals[d], curves[ deals[d].curve, sim, :] )

where the components are (roughly)

struct deal
    curve::CurveName
    tenor::Int64
end

curves = rand( numCurves, numSims, numTenors )  |> NamedArray
setnames!(curves, CurveNames )

value( d::deal, curve::Array{Int64} ) = curve[d.tenor]

You should check out Tullio.jl: GitHub - mcabbott/Tullio.jl: ⅀

Tullio is highly performant, but it looks like you have placed your curve data along the 3rd dimension of your array, which may harm performance, since Julia Arrays are column-major, unlike e.g. numpy arrays.

(Btw, type names are, by convention, Capitalized)

1 Like

Tullio looks really cool. Thank you. I’ll probably have some questions on it tomorrow.

Thanks re. Capitalization.

Thanks re. dimension order. I notice with X = ones(10000,10000)

@tullio Y[i] := sum( X[:,i] )

is much faster than

@tullio Y[i] := sum( X[i,:] )