Coder Social home page Coder Social logo

Comments (3)

Jutho avatar Jutho commented on June 24, 2024

I think this is mostly a problem of misunderstanding how expressions are parsed in Julia. A line break typically indicates the end of an expression, unless the parser detects that the expression does not make sense, in which case it will try to add the second line and ignore the line break.

So if you had written

@tensor begin
Riemann[ρ,σ,μ,ν] := 
g_inverse[ρ,f]*(g_∂[f,μ,λ] + g_∂[f,λ,μ] - g_∂[μ,λ,f])*g_inverse[λ,h]*(g_∂[h,ν,σ] + g_∂[h,σ,ν] - g_∂[ν,σ,h]) -
g_inverse[ρ,i]*(g_∂[i,ν,λ] + g_∂[i,λ,ν] - g_∂[ν,λ,i])*g_inverse[λ,k]*(g_∂[k,μ,σ] + g_∂[k,σ,μ] - g_∂[μ,σ,k])                                
end

This works fine. But your input is equivalent to

@tensor begin
Riemann[ρ,σ,μ,ν] :=  g_inverse[ρ,f]*(g_∂[f,μ,λ] + g_∂[f,λ,μ] - g_∂[μ,λ,f])*g_inverse[λ,h]*(g_∂[h,ν,σ] + g_∂[h,σ,ν] - g_∂[ν,σ,h])
end

and

@tensor begin
-g_inverse[ρ,i]*(g_∂[i,ν,λ] + g_∂[i,λ,ν] - g_∂[ν,λ,i])*g_inverse[λ,k]*(g_∂[k,μ,σ] + g_∂[k,σ,μ] - g_∂[μ,σ,k])                              
end

For this second case, TensorOperations will try to evaluate to a scalar (but of course fails), which would then be the return value of this block.

from tensoroperations.jl.

tomkimpson avatar tomkimpson commented on June 24, 2024

Yes you are right! Sorry I am a new Julia-er so didn't realise this is how it worked. Thanks for your help and apologies for the spam issue!

from tensoroperations.jl.

Jutho avatar Jutho commented on June 24, 2024

No problem, glad I could help out. You've got me worried for a second too, before I noticed the problem.

Also, the error messages of the @tensor macro need to be much improved, they are often very cryptic.

from tensoroperations.jl.

Related Issues (20)

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.