Giter Club home page Giter Club logo

Comments (9)

haampie avatar haampie commented on June 1, 2024 1

Thanks, I will look into that. There should be a fallback for this in Julia base when the mul!api is done

from arnoldimethod.jl.

sverek avatar sverek commented on June 1, 2024 1

Tack! :)

from arnoldimethod.jl.

andreasnoack avatar andreasnoack commented on June 1, 2024

Ref: JuliaLang/julia#29634 and
JuliaLang/julia#23919. Unfortunately, it seems that the discussion has dead locked.

from arnoldimethod.jl.

jarlebring avatar jarlebring commented on June 1, 2024

Workaround if you really need it and don't care about performance so much: Write your own fallback.

import LinearAlgebra.BLAS.gemv!
function gemv!(C,alpha,A,X,beta,Y)
     if (C=='N')
        Y[:]=alpha*A*X+beta*Y
    elseif (C=='T')
        Y[:]=alpha*transpose(A)*X+beta*Y
    elseif (C=='C')
        Y[:]=alpha*A'*X+beta*Y
    else 
        error("Unknown transpose character")
    end
end

Output:

julia> mwe()
10×10 SparseMatrixCSC{Float64,Int64} with 28 stored entries:
  [1 ,  1]  =  2.0
  [2 ,  1]  =  -1.0
  [1 ,  2]  =  -1.0
  [2 ,  2]  =  2.0
  [3 ,  2]  =  -1.0
  [2 ,  3]  =  -1.0
  [3 ,  3]  =  2.0
  [4 ,  3]  =  -1.0
  [3 ,  4]  =  -1.0
  [4 ,  4]  =  2.0
  [5 ,  4]  =  -1.0
  [4 ,  5]  =  -1.0
  
  [7 ,  6]  =  -1.0
  [6 ,  7]  =  -1.0
  [7 ,  7]  =  2.0
  [8 ,  7]  =  -1.0
  [7 ,  8]  =  -1.0
  [8 ,  8]  =  2.0
  [9 ,  8]  =  -1.0
  [8 ,  9]  =  -1.0
  [9 ,  9]  =  2.0
  [10,  9]  =  -1.0
  [9 , 10]  =  -1.0
  [10, 10]  =  2.0
PartialSchur decomposition (Float64) of dimension 10
eigenvalues:
10-element Array{Complex{Float64},1}:
 0.08101405277100521 + 0.0im
  0.3174929343376377 + 0.0im
  0.6902785321094296 + 0.0im
  1.1691699739962276 + 0.0im
  1.7153703234534308 + 0.0im
   2.284629676546571 + 0.0im
   2.830830026003773 + 0.0im
  3.3097214678905718 + 0.0im
   3.682507065662364 + 0.0im
   3.918985947228997 + 0.0im
10×10 SparseMatrixCSC{BigFloat,Int64} with 28 stored entries:
  [1 ,  1]  =  2.0
  [2 ,  1]  =  -1.0
  [1 ,  2]  =  -1.0
  [2 ,  2]  =  2.0
  [3 ,  2]  =  -1.0
  [2 ,  3]  =  -1.0
  [3 ,  3]  =  2.0
  [4 ,  3]  =  -1.0
  [3 ,  4]  =  -1.0
  [4 ,  4]  =  2.0
  [5 ,  4]  =  -1.0
  [4 ,  5]  =  -1.0
  
  [7 ,  6]  =  -1.0
  [6 ,  7]  =  -1.0
  [7 ,  7]  =  2.0
  [8 ,  7]  =  -1.0
  [7 ,  8]  =  -1.0
  [8 ,  8]  =  2.0
  [9 ,  8]  =  -1.0
  [8 ,  9]  =  -1.0
  [9 ,  9]  =  2.0
  [10,  9]  =  -1.0
  [9 , 10]  =  -1.0
  [10, 10]  =  2.0
PartialSchur decomposition (BigFloat) of dimension 10
eigenvalues:
10-element Array{Complex{BigFloat},1}:
 8.101405277100522021926388586734460187509030315567608991100988200961938340741451e-02 + 0.0im
 3.174929343376376622763767021612645649734150031589242027146997646366977861967341e-01 + 0.0im
 6.902785321094298718861498550674128936324176013261431447874087909882098201012722e-01 + 0.0im
     1.169169973996227148941451701540753592951990179070926375147553335243120438110192 + 0.0im
     1.715370323453429719112414662767260662417897277748031343163834426881989020798096 + 0.0im
     2.284629676546570280887585337232739337582102722251968656836165573118010979201559 + 0.0im
     2.830830026003772851058548298459246407048009820929073624852446664756879561889998 + 0.0im
     3.309721467890570128113850144932587106367582398673856855212591209011790179898892 + 0.0im
     3.682507065662362337723623297838735435026584996841075797285300235363302213803357 + 0.0im
     3.918985947228994779780736114132655398124909696844323910088990117990380616592766 + 0.0im
julia> 

from arnoldimethod.jl.

jarlebring avatar jarlebring commented on June 1, 2024

Any thoughts on adding tutorials in the online documentation? I think this workaround would be suitable there rather than doing some (dirty?) fix in the code.

from arnoldimethod.jl.

sverek avatar sverek commented on June 1, 2024

I really appreciate this example, very illuminating.

from arnoldimethod.jl.

fgerick avatar fgerick commented on June 1, 2024

What needs to be done to get this running for arbitrary number types? I'm very interested to have this working (I don't dare try to compile PETSc and SLEPc in 128 bit versions and somehow interface to it...).

from arnoldimethod.jl.

haampie avatar haampie commented on June 1, 2024

JuliaLang/julia#29634 landed in Julia in the meantime, so what has to be changed is

Remove
https://github.com/haampie/ArnoldiMethod.jl/blob/da85958072ec54c64c7dca8362eb42e572252f62/src/expansion.jl#L3

And replace https://github.com/haampie/ArnoldiMethod.jl/blob/da85958072ec54c64c7dca8362eb42e572252f62/src/expansion.jl#L35 by the corresponding mul! function

from arnoldimethod.jl.

fgerick avatar fgerick commented on June 1, 2024

Is the mul! change going to be in 1.3 when it is released? Anyways, for the moment I have just defined the gemv! for generic number types, as suggested by @jarlebring . There is also a problem in the lu function in schursort.jl related to StaticArrays of non-isbitstype numbers:

using ArnoldiMethod, LinearAlgebra
import LinearAlgebra.BLAS.gemv!
function gemv!(C,alpha,A,X,beta,Y)
    if (C=='N')
       Y.=alpha*A*X+beta*Y
    elseif (C=='T')
       Y.=alpha*transpose(A)*X+beta*Y
    elseif (C=='C')
       Y.=alpha*A'*X+beta*Y
    else
       error("Unknown transpose character")
    end
end

a=big.(randn(10,10))
partialschur(a)

leads to:

ERROR: setindex!() with non-isbitstype eltype is not supported by StaticArrays. Consider using SizedArray.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] setindex! at /Users/gerickf/.julia/packages/StaticArrays/DBECI/src/MArray.jl:109 [inlined]
 [3] macro expansion at /Users/gerickf/.julia/packages/StaticArrays/DBECI/src/indexing.jl:65 [inlined]
 [4] _setindex!_scalar at /Users/gerickf/.julia/packages/StaticArrays/DBECI/src/indexing.jl:46 [inlined]
 [5] setindex! at /Users/gerickf/.julia/packages/StaticArrays/DBECI/src/indexing.jl:42 [inlined]
 [6] lu(::StaticArrays.SArray{Tuple{2,2},BigFloat,2,4}, ::Type{ArnoldiMethod.CompletePivoting}) at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/schursort.jl:98
 [7] sylv at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/schursort.jl:184 [inlined]
 [8] swap12!(::Array{BigFloat,2}, ::Int64, ::Array{BigFloat,2}) at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/schursort.jl:408
 [9] swap! at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/schursort.jl:479 [inlined]
 [10] rotate_right!(::Array{BigFloat,2}, ::Int64, ::Int64, ::Array{BigFloat,2}) at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/schursort.jl:27
 [11] partition_schur_three_way!(::Array{BigFloat,2}, ::Array{BigFloat,2}, ::Array{Int64,1}) at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/run.jl:348
 [12] _partialschur(::Array{BigFloat,2}, ::Type{BigFloat}, ::Int64, ::Int64, ::Int64, ::BigFloat, ::Int64, ::LM) at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/run.jl:254
 [13] #partialschur#1 at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/run.jl:103 [inlined]
 [14] partialschur(::Array{BigFloat,2}) at /Users/gerickf/.julia/packages/ArnoldiMethod/5fDBS/src/run.jl:101
 [15] top-level scope at none:0

Does changing to SizedArray come with a big caveat?

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