Skip to content

linear solve of tridiagonal system #2707

@marcobonici

Description

@marcobonici

When trying to invert a tridiagonal system and compiling that function with Reactant, I get an error.

Here the MWE

using Reactant
using LinearAlgebra

Reactant.set_default_backend("cpu")

# Minimal tridiagonal system
n = 5

dl = Float32[1, 1, 1, 1]
 d = Float32[4, 4, 4, 4, 4]
 du = Float32[1, 1, 1, 1]
 b = Float32[1, 2, 3, 4, 5]

# Trace all inputs
 dlR = Reactant.to_rarray(dl)
  dR = Reactant.to_rarray(d)
 duR = Reactant.to_rarray(du)
  bR = Reactant.to_rarray(b)

function solve_tridiagonal(dl, d, du, b)
    A = Tridiagonal(dl, d, du)
    return A \ b
end

println("=== Reactant Tridiagonal MWE ===")
try
    f = Reactant.@compile solve_tridiagonal(dlR, dR, duR, bR)
    y = f(dlR, dR, duR, bR)
    println("SUCCESS: ", y)
catch e
    println("FAIL: ", typeof(e))
    println(e)
end

here the output

=== Reactant Tridiagonal MWE ===
FAIL: TypeError
TypeError(:typeassert, "", Bool, TracedRNumber{Bool}(()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions