# TensorsOperations, lookups and functions

**URL:** <https://discourse.julialang.org/t/tensorsoperations-lookups-and-functions/85140>\
**Category:** General Usage\
**Tags:** tullio, tensoroperations\
**Created:** [August 2, 2022, 4:49am UTC](https://discourse.julialang.org/t/tensorsoperations-lookups-and-functions/85140 "2022-08-02T04:49:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [August 2, 2022, 4:49am UTC](https://discourse.julialang.org/t/tensorsoperations-lookups-and-functions/85140/1 "2022-08-02T04:49:25Z")

</div>

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)

```julia
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]

```

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 2, 2022, 5:18am UTC](https://discourse.julialang.org/t/tensorsoperations-lookups-and-functions/85140/2 "2022-08-02T05:18:56Z")

</div>

You should check out Tullio.jl: [GitHub - mcabbott/Tullio.jl: ⅀](https://github.com/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 `Array`s are column-major, unlike e.g. numpy arrays.

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

---

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [August 2, 2022, 6:00am UTC](https://discourse.julialang.org/t/tensorsoperations-lookups-and-functions/85140/3 "2022-08-02T06:00:17Z")

</div>

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,:] )`

```julia

```
