Coder Social home page Coder Social logo

Comments (15)

zahachtah avatar zahachtah commented on May 29, 2024

this seems to fix it:

function recursivecopy!(b::AbstractMultiScaleArray, a::AbstractMultiScaleArray)
    @inbounds for i in eachindex(a.nodes)
        recursivecopy!(b.nodes[i], a.nodes[i])
    end
    @inbounds for i in eachindex(a.values)
        #recursivecopy!(b.values[i], a.values[i])
        copyto!(b.values,a.values)
    end
end

from multiscalearrays.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 29, 2024

What's the type of values? The better solution is just to add a dispatch to recursivecopy! to that way it does copyto! in this case.

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

At that point its Float64’s

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

If the values is an array of Float64 then this

’’’recursivecopy!(b.values[i], a.values[i])’’’

should dispatch on Float64’s

from multiscalearrays.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 29, 2024

oh, it should just be recursivecopy!(b.values, a.values).

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

Ah, right.

Also: i tried to use namedTuples instead of an array of float64 but wasn’t sure if 1) it should work or 2) how to change the typeParsmetrization. Any quick ideas? Don’t want to waste your time though

from multiscalearrays.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 29, 2024

It should work the same way we have tuples working. If not, we'll need an example.

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

this is what I am trying to do

struct scale1{B,V<:NamedTuple{Vararg{<:Array{<:Number}}},P,N<:Tuple{Vararg{<:AbstractMultiScaleArrayLeaf{<:Number}}}} <: AbstractMultiScaleArray{B}
    nodes::N
    values::V
    end_idxs::Vector{Int}
    params::P
end

so I can construct it with

s1A = construct(scale1, (deepcopy(t1), deepcopy(t2)), (a=0.1,b=2.0), [0.1,0.2])

where t1 and t2 are lower level nodes

But this gives type-error

from multiscalearrays.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 29, 2024

How does it give a type error? Where? I need an example.

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

already when running the above definition of the struct:

TypeError: in Type, in parameter, expected Type, got Type{Vararg{#s37,N} where N where #s37<:(Array{#s36,N} where N where #s36<:Number)}

Stacktrace:
 [1] top-level scope at none:0

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

Closing, don't worry reg the named tuple question, I have to read up on how type parametrizations work. As always, thanks for the great package.

from multiscalearrays.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 29, 2024

So it had to do with the struct definition?

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

yes. but I also realize I wanted the named tuple as an array for the values which have to be mutable for the ode solver so that doesnt work. I mostly thought it would be neat to be able to write things like

u[:energy] in the differential equations instead of e.g. u[3].

but named tuples are are immutable of course so that doesn't make sense. But I have what I need now I think. Thanks

from multiscalearrays.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 29, 2024

I'm working towards a solution: https://github.com/JuliaDiffEq/LabelledArrays.jl

from multiscalearrays.jl.

zahachtah avatar zahachtah commented on May 29, 2024

Oh, that would make it super pretty to write down the equations.

I remember Tom Breloff had this cool macro (I think it was called @with) so that if used you didn't even have to write A.second (he used if for structs) but you could just write second or :second and it would fill out the rest at compile time. I gues sone could do that for

@with a  

that would turn

: second -> a[:second]

making it even prettier. This is awesome. I guess if you have the map between names and indicies the macro could do that right away too....

julia sure is amazing!

from multiscalearrays.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.