From b447608af61a2ac1b7266f21b2ce21218d021f0d Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Sun, 21 Apr 2024 09:49:00 -0400 Subject: [PATCH] Use Clang.jl to generate the Julia wrappers --- gen/Project.toml | 7 + gen/README.md | 10 + gen/qrmumps.toml | 12 + gen/wrapper.jl | 54 ++++ src/QRMumps.jl | 1 + src/wrapper/libqrmumps.jl | 613 ++++++++++++++++++++++++++++++++++++ src/wrapper/qr_mumps_api.jl | 310 +++++++++--------- test/test_qrm.jl | 2 +- 8 files changed, 852 insertions(+), 157 deletions(-) create mode 100644 gen/Project.toml create mode 100644 gen/README.md create mode 100644 gen/qrmumps.toml create mode 100644 gen/wrapper.jl create mode 100644 src/wrapper/libqrmumps.jl diff --git a/gen/Project.toml b/gen/Project.toml new file mode 100644 index 0000000..94b8572 --- /dev/null +++ b/gen/Project.toml @@ -0,0 +1,7 @@ +[deps] +Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" +qr_mumps_jll = "e37b5aa0-c611-5f0f-83fb-aee446c0b77e" +JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" + +[compat] +julia = "1.6" diff --git a/gen/README.md b/gen/README.md new file mode 100644 index 0000000..7284696 --- /dev/null +++ b/gen/README.md @@ -0,0 +1,10 @@ +# Wrapping headers + +This directory contains a script that can be used to automatically generate wrappers from C headers provided by qr_mumps. +This is done using Clang.jl. + +# Usage + +Either run `julia wrapper.jl` directly, or include it and call the `main()` function. +Be sure to activate the project environment in this folder (`julia --project`), which will install `Clang.jl` and `JuliaFormatter.jl`. +The `main` function supports the boolean keyword argument `optimized` to clear the generated wrappers. diff --git a/gen/qrmumps.toml b/gen/qrmumps.toml new file mode 100644 index 0000000..6c119c4 --- /dev/null +++ b/gen/qrmumps.toml @@ -0,0 +1,12 @@ +[general] +use_julia_native_enum_type = true +print_using_CEnum = false +library_names = {"sqrm_c.h" = "libsqrm", "dqrm_c.h" = "libdqrm", "cqrm_c.h" = "libcqrm", "zqrm_c.h" = "libzqrm", "qrm_common_c.h" = "libqrm_common"} + +[codegen] +use_julia_bool = true +always_NUL_terminated_string = true +use_ccall_macro = true + +[codegen.macro] +macro_mode = "disable" diff --git a/gen/wrapper.jl b/gen/wrapper.jl new file mode 100644 index 0000000..be08447 --- /dev/null +++ b/gen/wrapper.jl @@ -0,0 +1,54 @@ +# Script to parse qr_mumps headers and generate Julia wrappers. +using qr_mumps_jll +using Clang +using Clang.Generators +using JuliaFormatter + +function main() + + cd(@__DIR__) + include_dir = joinpath(qr_mumps_jll.artifact_dir, "include") + headers = map(header -> joinpath(include_dir, header), ["sqrm_c.h", "dqrm_c.h", "cqrm_c.h", "zqrm_c.h", "qrm_common_c.h"]) + + options = load_options(joinpath(@__DIR__, "qrmumps.toml")) + options["general"]["output_file_path"] = joinpath("..", "src", "wrapper", "libqrmumps.jl") + options["general"]["output_ignorelist"] = ["[sdcz]qrm_spmat_type_c", "[sdcz]qrm_spfct_type_c", "icntl", "rcntl", "ords", "gstats", "yn"] + + args = get_default_args() + push!(args, "-I$include_dir") + + ctx = create_context(headers, args, options) + build!(ctx) + + path = options["general"]["output_file_path"] + + code = read(path, String) + for pattern in ("::", ",", ")") + qrm_spmat_c = "qrm_spmat_c" * pattern + spmat = "spmat" * pattern + code = replace(code, qrm_spmat_c => spmat) + + qrm_spfct_c = "qrm_sptct_c" * pattern + spfct = "spfct" * pattern + code = replace(code, qrm_spfct_c => spfct) + end + + for (version, type) in [("s", "Float32"), ("d", "Float64"), ("c", "ComplexF32"), ("z", "ComplexF64")] + type_spmat_c = "Ptr{" * version * "qrm_spmat_type_c}" + type_spmat_julia = "Ref{c_spmat{" * type * "}}" + code = replace(code, type_spmat_c => type_spmat_julia) + + type_spfct_c = "Ptr{" * version * "qrm_spfct_type_c}" + type_spfct_julia = "Ref{c_spfct{" * type * "}}" + code = replace(code, type_spfct_c => type_spfct_julia) + end + write(path, code) + + format_file(path, YASStyle()) + return nothing +end + +# If we want to use the file as a script with `julia wrapper.jl` +if abspath(PROGRAM_FILE) == @__FILE__ + main() +end diff --git a/src/QRMumps.jl b/src/QRMumps.jl index 13b0e54..776a701 100644 --- a/src/QRMumps.jl +++ b/src/QRMumps.jl @@ -22,6 +22,7 @@ else end include("wrapper/qr_mumps_common.jl") +include("wrapper/libqrmumps.jl") include("wrapper/qr_mumps_api.jl") export qrm_spmat, qrm_spfct, diff --git a/src/wrapper/libqrmumps.jl b/src/wrapper/libqrmumps.jl new file mode 100644 index 0000000..ba3811c --- /dev/null +++ b/src/wrapper/libqrmumps.jl @@ -0,0 +1,613 @@ +function sqrm_spmat_init_c(spmat) + @ccall libsqrm.sqrm_spmat_init_c(spmat::Ref{c_spmat{Float32}})::Cint +end + +function sqrm_spmat_destroy_c(spmat) + @ccall libsqrm.sqrm_spmat_destroy_c(spmat::Ref{c_spmat{Float32}})::Cint +end + +function sqrm_spfct_init_c(spfct, spmat) + @ccall libsqrm.sqrm_spfct_init_c(spfct::Ref{c_spfct{Float32}}, + spmat::Ref{c_spmat{Float32}})::Cint +end + +function sqrm_spfct_destroy_c(spfct) + @ccall libsqrm.sqrm_spfct_destroy_c(spfct::Ref{c_spfct{Float32}})::Cint +end + +function sqrm_analyse_c(spmat, spfct, transp) + @ccall libsqrm.sqrm_analyse_c(spmat::Ref{c_spmat{Float32}}, + spfct::Ref{c_spfct{Float32}}, transp::Cchar)::Cint +end + +function sqrm_factorize_c(spmat, spfct, transp) + @ccall libsqrm.sqrm_factorize_c(spmat::Ref{c_spmat{Float32}}, + spfct::Ref{c_spfct{Float32}}, transp::Cchar)::Cint +end + +function sqrm_solve_c(spfct, transp, b, x, nrhs) + @ccall libsqrm.sqrm_solve_c(spfct::Ref{c_spfct{Float32}}, transp::Cchar, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint)::Cint +end + +function sqrm_apply_c(spfct, transp, b, nrhs) + @ccall libsqrm.sqrm_apply_c(spfct::Ref{c_spfct{Float32}}, transp::Cchar, b::Ptr{Cfloat}, + nrhs::Cint)::Cint +end + +function sqrm_spmat_mv_c(spmat, transp, alpha, x, beta, y, nrhs) + @ccall libsqrm.sqrm_spmat_mv_c(spmat::Ref{c_spmat{Float32}}, transp::Cchar, + alpha::Cfloat, x::Ptr{Cfloat}, beta::Cfloat, + y::Ptr{Cfloat}, nrhs::Cint)::Cint +end + +function sqrm_spmat_nrm_c(spmat, ntype, nrm) + @ccall libsqrm.sqrm_spmat_nrm_c(spmat::Ref{c_spmat{Float32}}, ntype::Cchar, + nrm::Ptr{Cfloat})::Cint +end + +function sqrm_vecnrm_c(x, n, nrhs, ntype, nrm) + @ccall libsqrm.sqrm_vecnrm_c(x::Ptr{Cfloat}, n::Cint, nrhs::Cint, ntype::Cchar, + nrm::Ptr{Cfloat})::Cint +end + +function sqrm_spbackslash_c(spmat, b, x, nrhs, transp) + @ccall libsqrm.sqrm_spbackslash_c(spmat::Ref{c_spmat{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint, transp::Cchar)::Cint +end + +function sqrm_spfct_backslash_c(spfct, b, x, nrhs, transp) + @ccall libsqrm.sqrm_spfct_backslash_c(spfct::Ref{c_spfct{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint, transp::Cchar)::Cint +end + +function sqrm_spposv_c(spmat, b, x, nrhs) + @ccall libsqrm.sqrm_spposv_c(spmat::Ref{c_spmat{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint)::Cint +end + +function sqrm_least_squares_c(spmat, b, x, nrhs, transp) + @ccall libsqrm.sqrm_least_squares_c(spmat::Ref{c_spmat{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint, transp::Cchar)::Cint +end + +function sqrm_min_norm_c(spmat, b, x, nrhs, transp) + @ccall libsqrm.sqrm_min_norm_c(spmat::Ref{c_spmat{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint, transp::Cchar)::Cint +end + +function sqrm_residual_norm_c(spmat, b, x, nrhs, nrm, transp) + @ccall libsqrm.sqrm_residual_norm_c(spmat::Ref{c_spmat{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint, nrm::Ptr{Cfloat}, + transp::Cchar)::Cint +end + +function sqrm_residual_orth_c(spmat, r, nrhs, nrm, transp) + @ccall libsqrm.sqrm_residual_orth_c(spmat::Ref{c_spmat{Float32}}, r::Ptr{Cfloat}, + nrhs::Cint, nrm::Ptr{Cfloat}, transp::Cchar)::Cint +end + +function sqrm_spfct_trsm_c(spfct, transp, b, x, nrhs) + @ccall libsqrm.sqrm_spfct_trsm_c(spfct::Ref{c_spfct{Float32}}, transp::Cchar, + b::Ptr{Cfloat}, x::Ptr{Cfloat}, nrhs::Cint)::Cint +end + +function sqrm_spfct_sytrs_c(spfct, b, x, nrhs) + @ccall libsqrm.sqrm_spfct_sytrs_c(spfct::Ref{c_spfct{Float32}}, b::Ptr{Cfloat}, + x::Ptr{Cfloat}, nrhs::Cint)::Cint +end + +function sqrm_spfct_set_i4_c(spfct, string, val) + @ccall libsqrm.sqrm_spfct_set_i4_c(spfct::Ref{c_spfct{Float32}}, string::Cstring, + val::Cint)::Cint +end + +function sqrm_spfct_set_r4_c(spfct, string, val) + @ccall libsqrm.sqrm_spfct_set_r4_c(spfct::Ref{c_spfct{Float32}}, string::Cstring, + val::Cfloat)::Cint +end + +function sqrm_spfct_get_i4_c(spfct, string, val) + @ccall libsqrm.sqrm_spfct_get_i4_c(spfct::Ref{c_spfct{Float32}}, string::Cstring, + val::Ptr{Cint})::Cint +end + +function sqrm_spfct_get_r4_c(spfct, string, val) + @ccall libsqrm.sqrm_spfct_get_r4_c(spfct::Ref{c_spfct{Float32}}, string::Cstring, + val::Ptr{Cfloat})::Cint +end + +function sqrm_spfct_get_i8_c(spfct, string, val) + @ccall libsqrm.sqrm_spfct_get_i8_c(spfct::Ref{c_spfct{Float32}}, string::Cstring, + val::Ptr{Clonglong})::Cint +end + +function sqrm_spfct_get_schur_c(spfct, s, i, j, m, n) + @ccall libsqrm.sqrm_spfct_get_schur_c(spfct::Ref{c_spfct{Float32}}, s::Ptr{Cfloat}, + i::Cint, j::Cint, m::Cint, n::Cint)::Cint +end + +function sqrm_spfct_get_r_c(spfct, spmat) + @ccall libsqrm.sqrm_spfct_get_r_c(spfct::Ref{c_spfct{Float32}}, + spmat::Ref{c_spmat{Float32}})::Cint +end + +function sqrm_spfct_get_cp_c(spfct, cp) + @ccall libsqrm.sqrm_spfct_get_cp_c(spfct::Ref{c_spfct{Float32}}, + cp::Ptr{Ptr{Cint}})::Cint +end + +function sqrm_spfct_get_rp_c(spfct, rp) + @ccall libsqrm.sqrm_spfct_get_rp_c(spfct::Ref{c_spfct{Float32}}, + rp::Ptr{Ptr{Cint}})::Cint +end + +function dqrm_spmat_init_c(spmat) + @ccall libdqrm.dqrm_spmat_init_c(spmat::Ref{c_spmat{Float64}})::Cint +end + +function dqrm_spmat_destroy_c(spmat) + @ccall libdqrm.dqrm_spmat_destroy_c(spmat::Ref{c_spmat{Float64}})::Cint +end + +function dqrm_spfct_init_c(spfct, spmat) + @ccall libdqrm.dqrm_spfct_init_c(spfct::Ref{c_spfct{Float64}}, + spmat::Ref{c_spmat{Float64}})::Cint +end + +function dqrm_spfct_destroy_c(spfct) + @ccall libdqrm.dqrm_spfct_destroy_c(spfct::Ref{c_spfct{Float64}})::Cint +end + +function dqrm_analyse_c(spmat, spfct, transp) + @ccall libdqrm.dqrm_analyse_c(spmat::Ref{c_spmat{Float64}}, + spfct::Ref{c_spfct{Float64}}, transp::Cchar)::Cint +end + +function dqrm_factorize_c(spmat, spfct, transp) + @ccall libdqrm.dqrm_factorize_c(spmat::Ref{c_spmat{Float64}}, + spfct::Ref{c_spfct{Float64}}, transp::Cchar)::Cint +end + +function dqrm_solve_c(spfct, transp, b, x, nrhs) + @ccall libdqrm.dqrm_solve_c(spfct::Ref{c_spfct{Float64}}, transp::Cchar, + b::Ptr{Cdouble}, x::Ptr{Cdouble}, nrhs::Cint)::Cint +end + +function dqrm_apply_c(spfct, transp, b, nrhs) + @ccall libdqrm.dqrm_apply_c(spfct::Ref{c_spfct{Float64}}, transp::Cchar, + b::Ptr{Cdouble}, nrhs::Cint)::Cint +end + +function dqrm_spmat_mv_c(spmat, transp, alpha, x, beta, y, nrhs) + @ccall libdqrm.dqrm_spmat_mv_c(spmat::Ref{c_spmat{Float64}}, transp::Cchar, + alpha::Cdouble, x::Ptr{Cdouble}, beta::Cdouble, + y::Ptr{Cdouble}, nrhs::Cint)::Cint +end + +function dqrm_spmat_nrm_c(spmat, ntype, nrm) + @ccall libdqrm.dqrm_spmat_nrm_c(spmat::Ref{c_spmat{Float64}}, ntype::Cchar, + nrm::Ptr{Cdouble})::Cint +end + +function dqrm_vecnrm_c(x, n, nrhs, ntype, nrm) + @ccall libdqrm.dqrm_vecnrm_c(x::Ptr{Cdouble}, n::Cint, nrhs::Cint, ntype::Cchar, + nrm::Ptr{Cdouble})::Cint +end + +function dqrm_spbackslash_c(spmat, b, x, nrhs, transp) + @ccall libdqrm.dqrm_spbackslash_c(spmat::Ref{c_spmat{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint, transp::Cchar)::Cint +end + +function dqrm_spfct_backslash_c(spfct, b, x, nrhs, transp) + @ccall libdqrm.dqrm_spfct_backslash_c(spfct::Ref{c_spfct{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint, transp::Cchar)::Cint +end + +function dqrm_spposv_c(spmat, b, x, nrhs) + @ccall libdqrm.dqrm_spposv_c(spmat::Ref{c_spmat{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint)::Cint +end + +function dqrm_least_squares_c(spmat, b, x, nrhs, transp) + @ccall libdqrm.dqrm_least_squares_c(spmat::Ref{c_spmat{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint, transp::Cchar)::Cint +end + +function dqrm_min_norm_c(spmat, b, x, nrhs, transp) + @ccall libdqrm.dqrm_min_norm_c(spmat::Ref{c_spmat{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint, transp::Cchar)::Cint +end + +function dqrm_residual_norm_c(spmat, b, x, nrhs, nrm, transp) + @ccall libdqrm.dqrm_residual_norm_c(spmat::Ref{c_spmat{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint, nrm::Ptr{Cdouble}, + transp::Cchar)::Cint +end + +function dqrm_residual_orth_c(spmat, r, nrhs, nrm, transp) + @ccall libdqrm.dqrm_residual_orth_c(spmat::Ref{c_spmat{Float64}}, r::Ptr{Cdouble}, + nrhs::Cint, nrm::Ptr{Cdouble}, transp::Cchar)::Cint +end + +function dqrm_spfct_trsm_c(spfct, transp, b, x, nrhs) + @ccall libdqrm.dqrm_spfct_trsm_c(spfct::Ref{c_spfct{Float64}}, transp::Cchar, + b::Ptr{Cdouble}, x::Ptr{Cdouble}, nrhs::Cint)::Cint +end + +function dqrm_spfct_sytrs_c(spfct, b, x, nrhs) + @ccall libdqrm.dqrm_spfct_sytrs_c(spfct::Ref{c_spfct{Float64}}, b::Ptr{Cdouble}, + x::Ptr{Cdouble}, nrhs::Cint)::Cint +end + +function dqrm_spfct_set_i4_c(spfct, string, val) + @ccall libdqrm.dqrm_spfct_set_i4_c(spfct::Ref{c_spfct{Float64}}, string::Cstring, + val::Cint)::Cint +end + +function dqrm_spfct_set_r4_c(spfct, string, val) + @ccall libdqrm.dqrm_spfct_set_r4_c(spfct::Ref{c_spfct{Float64}}, string::Cstring, + val::Cfloat)::Cint +end + +function dqrm_spfct_get_i4_c(spfct, string, val) + @ccall libdqrm.dqrm_spfct_get_i4_c(spfct::Ref{c_spfct{Float64}}, string::Cstring, + val::Ptr{Cint})::Cint +end + +function dqrm_spfct_get_r4_c(spfct, string, val) + @ccall libdqrm.dqrm_spfct_get_r4_c(spfct::Ref{c_spfct{Float64}}, string::Cstring, + val::Ptr{Cfloat})::Cint +end + +function dqrm_spfct_get_i8_c(spfct, string, val) + @ccall libdqrm.dqrm_spfct_get_i8_c(spfct::Ref{c_spfct{Float64}}, string::Cstring, + val::Ptr{Clonglong})::Cint +end + +function dqrm_spfct_get_schur_c(spfct, s, i, j, m, n) + @ccall libdqrm.dqrm_spfct_get_schur_c(spfct::Ref{c_spfct{Float64}}, s::Ptr{Cdouble}, + i::Cint, j::Cint, m::Cint, n::Cint)::Cint +end + +function dqrm_spfct_get_r_c(spfct, spmat) + @ccall libdqrm.dqrm_spfct_get_r_c(spfct::Ref{c_spfct{Float64}}, + spmat::Ref{c_spmat{Float64}})::Cint +end + +function dqrm_spfct_get_cp_c(spfct, cp) + @ccall libdqrm.dqrm_spfct_get_cp_c(spfct::Ref{c_spfct{Float64}}, + cp::Ptr{Ptr{Cint}})::Cint +end + +function dqrm_spfct_get_rp_c(spfct, rp) + @ccall libdqrm.dqrm_spfct_get_rp_c(spfct::Ref{c_spfct{Float64}}, + rp::Ptr{Ptr{Cint}})::Cint +end + +function cqrm_spmat_init_c(spmat) + @ccall libcqrm.cqrm_spmat_init_c(spmat::Ref{c_spmat{ComplexF32}})::Cint +end + +function cqrm_spmat_destroy_c(spmat) + @ccall libcqrm.cqrm_spmat_destroy_c(spmat::Ref{c_spmat{ComplexF32}})::Cint +end + +function cqrm_spfct_init_c(spfct, spmat) + @ccall libcqrm.cqrm_spfct_init_c(spfct::Ref{c_spfct{ComplexF32}}, + spmat::Ref{c_spmat{ComplexF32}})::Cint +end + +function cqrm_spfct_destroy_c(spfct) + @ccall libcqrm.cqrm_spfct_destroy_c(spfct::Ref{c_spfct{ComplexF32}})::Cint +end + +function cqrm_analyse_c(spmat, spfct, transp) + @ccall libcqrm.cqrm_analyse_c(spmat::Ref{c_spmat{ComplexF32}}, + spfct::Ref{c_spfct{ComplexF32}}, transp::Cchar)::Cint +end + +function cqrm_factorize_c(spmat, spfct, transp) + @ccall libcqrm.cqrm_factorize_c(spmat::Ref{c_spmat{ComplexF32}}, + spfct::Ref{c_spfct{ComplexF32}}, transp::Cchar)::Cint +end + +function cqrm_solve_c(spfct, transp, b, x, nrhs) + @ccall libcqrm.cqrm_solve_c(spfct::Ref{c_spfct{ComplexF32}}, transp::Cchar, + b::Ptr{ComplexF32}, x::Ptr{ComplexF32}, nrhs::Cint)::Cint +end + +function cqrm_apply_c(spfct, transp, b, nrhs) + @ccall libcqrm.cqrm_apply_c(spfct::Ref{c_spfct{ComplexF32}}, transp::Cchar, + b::Ptr{ComplexF32}, nrhs::Cint)::Cint +end + +function cqrm_spmat_mv_c(spmat, transp, alpha, x, beta, y, nrhs) + @ccall libcqrm.cqrm_spmat_mv_c(spmat::Ref{c_spmat{ComplexF32}}, transp::Cchar, + alpha::ComplexF32, x::Ptr{ComplexF32}, beta::ComplexF32, + y::Ptr{ComplexF32}, nrhs::Cint)::Cint +end + +function cqrm_spmat_nrm_c(spmat, ntype, nrm) + @ccall libcqrm.cqrm_spmat_nrm_c(spmat::Ref{c_spmat{ComplexF32}}, ntype::Cchar, + nrm::Ptr{Cfloat})::Cint +end + +function cqrm_vecnrm_c(x, n, nrhs, ntype, nrm) + @ccall libcqrm.cqrm_vecnrm_c(x::Ptr{ComplexF32}, n::Cint, nrhs::Cint, ntype::Cchar, + nrm::Ptr{Cfloat})::Cint +end + +function cqrm_spbackslash_c(spmat, b, x, nrhs, transp) + @ccall libcqrm.cqrm_spbackslash_c(spmat::Ref{c_spmat{ComplexF32}}, b::Ptr{ComplexF32}, + x::Ptr{ComplexF32}, nrhs::Cint, transp::Cchar)::Cint +end + +function cqrm_spfct_backslash_c(spfct, b, x, nrhs, transp) + @ccall libcqrm.cqrm_spfct_backslash_c(spfct::Ref{c_spfct{ComplexF32}}, + b::Ptr{ComplexF32}, x::Ptr{ComplexF32}, + nrhs::Cint, transp::Cchar)::Cint +end + +function cqrm_spposv_c(spmat, b, x, nrhs) + @ccall libcqrm.cqrm_spposv_c(spmat::Ref{c_spmat{ComplexF32}}, b::Ptr{ComplexF32}, + x::Ptr{ComplexF32}, nrhs::Cint)::Cint +end + +function cqrm_least_squares_c(spmat, b, x, nrhs, transp) + @ccall libcqrm.cqrm_least_squares_c(spmat::Ref{c_spmat{ComplexF32}}, b::Ptr{ComplexF32}, + x::Ptr{ComplexF32}, nrhs::Cint, transp::Cchar)::Cint +end + +function cqrm_min_norm_c(spmat, b, x, nrhs, transp) + @ccall libcqrm.cqrm_min_norm_c(spmat::Ref{c_spmat{ComplexF32}}, b::Ptr{ComplexF32}, + x::Ptr{ComplexF32}, nrhs::Cint, transp::Cchar)::Cint +end + +function cqrm_residual_norm_c(spmat, b, x, nrhs, nrm, transp) + @ccall libcqrm.cqrm_residual_norm_c(spmat::Ref{c_spmat{ComplexF32}}, b::Ptr{ComplexF32}, + x::Ptr{ComplexF32}, nrhs::Cint, nrm::Ptr{Cfloat}, + transp::Cchar)::Cint +end + +function cqrm_residual_orth_c(spmat, r, nrhs, nrm, transp) + @ccall libcqrm.cqrm_residual_orth_c(spmat::Ref{c_spmat{ComplexF32}}, r::Ptr{ComplexF32}, + nrhs::Cint, nrm::Ptr{Cfloat}, transp::Cchar)::Cint +end + +function cqrm_spfct_trsm_c(spfct, transp, b, x, nrhs) + @ccall libcqrm.cqrm_spfct_trsm_c(spfct::Ref{c_spfct{ComplexF32}}, transp::Cchar, + b::Ptr{ComplexF32}, x::Ptr{ComplexF32}, + nrhs::Cint)::Cint +end + +function cqrm_spfct_sytrs_c(spfct, b, x, nrhs) + @ccall libcqrm.cqrm_spfct_sytrs_c(spfct::Ref{c_spfct{ComplexF32}}, b::Ptr{ComplexF32}, + x::Ptr{ComplexF32}, nrhs::Cint)::Cint +end + +function cqrm_spfct_set_i4_c(spfct, string, val) + @ccall libcqrm.cqrm_spfct_set_i4_c(spfct::Ref{c_spfct{ComplexF32}}, string::Cstring, + val::Cint)::Cint +end + +function cqrm_spfct_set_r4_c(spfct, string, val) + @ccall libcqrm.cqrm_spfct_set_r4_c(spfct::Ref{c_spfct{ComplexF32}}, string::Cstring, + val::Cfloat)::Cint +end + +function cqrm_spfct_get_i4_c(spfct, string, val) + @ccall libcqrm.cqrm_spfct_get_i4_c(spfct::Ref{c_spfct{ComplexF32}}, string::Cstring, + val::Ptr{Cint})::Cint +end + +function cqrm_spfct_get_r4_c(spfct, string, val) + @ccall libcqrm.cqrm_spfct_get_r4_c(spfct::Ref{c_spfct{ComplexF32}}, string::Cstring, + val::Ptr{Cfloat})::Cint +end + +function cqrm_spfct_get_i8_c(spfct, string, val) + @ccall libcqrm.cqrm_spfct_get_i8_c(spfct::Ref{c_spfct{ComplexF32}}, string::Cstring, + val::Ptr{Clonglong})::Cint +end + +function cqrm_spfct_get_schur_c(spfct, s, i, j, m, n) + @ccall libcqrm.cqrm_spfct_get_schur_c(spfct::Ref{c_spfct{ComplexF32}}, + s::Ptr{ComplexF32}, i::Cint, j::Cint, m::Cint, + n::Cint)::Cint +end + +function cqrm_spfct_get_r_c(spfct, spmat) + @ccall libcqrm.cqrm_spfct_get_r_c(spfct::Ref{c_spfct{ComplexF32}}, + spmat::Ref{c_spmat{ComplexF32}})::Cint +end + +function cqrm_spfct_get_cp_c(spfct, cp) + @ccall libcqrm.cqrm_spfct_get_cp_c(spfct::Ref{c_spfct{ComplexF32}}, + cp::Ptr{Ptr{Cint}})::Cint +end + +function cqrm_spfct_get_rp_c(spfct, rp) + @ccall libcqrm.cqrm_spfct_get_rp_c(spfct::Ref{c_spfct{ComplexF32}}, + rp::Ptr{Ptr{Cint}})::Cint +end + +function zqrm_spmat_init_c(spmat) + @ccall libzqrm.zqrm_spmat_init_c(spmat::Ref{c_spmat{ComplexF64}})::Cint +end + +function zqrm_spmat_destroy_c(spmat) + @ccall libzqrm.zqrm_spmat_destroy_c(spmat::Ref{c_spmat{ComplexF64}})::Cint +end + +function zqrm_spfct_init_c(spfct, spmat) + @ccall libzqrm.zqrm_spfct_init_c(spfct::Ref{c_spfct{ComplexF64}}, + spmat::Ref{c_spmat{ComplexF64}})::Cint +end + +function zqrm_spfct_destroy_c(spfct) + @ccall libzqrm.zqrm_spfct_destroy_c(spfct::Ref{c_spfct{ComplexF64}})::Cint +end + +function zqrm_analyse_c(spmat, spfct, transp) + @ccall libzqrm.zqrm_analyse_c(spmat::Ref{c_spmat{ComplexF64}}, + spfct::Ref{c_spfct{ComplexF64}}, transp::Cchar)::Cint +end + +function zqrm_factorize_c(spmat, spfct, transp) + @ccall libzqrm.zqrm_factorize_c(spmat::Ref{c_spmat{ComplexF64}}, + spfct::Ref{c_spfct{ComplexF64}}, transp::Cchar)::Cint +end + +function zqrm_solve_c(spfct, transp, b, x, nrhs) + @ccall libzqrm.zqrm_solve_c(spfct::Ref{c_spfct{ComplexF64}}, transp::Cchar, + b::Ptr{ComplexF64}, x::Ptr{ComplexF64}, nrhs::Cint)::Cint +end + +function zqrm_apply_c(spfct, transp, b, nrhs) + @ccall libzqrm.zqrm_apply_c(spfct::Ref{c_spfct{ComplexF64}}, transp::Cchar, + b::Ptr{ComplexF64}, nrhs::Cint)::Cint +end + +function zqrm_spmat_mv_c(spmat, transp, alpha, x, beta, y, nrhs) + @ccall libzqrm.zqrm_spmat_mv_c(spmat::Ref{c_spmat{ComplexF64}}, transp::Cchar, + alpha::ComplexF64, x::Ptr{ComplexF64}, beta::ComplexF64, + y::Ptr{ComplexF64}, nrhs::Cint)::Cint +end + +function zqrm_spmat_nrm_c(spmat, ntype, nrm) + @ccall libzqrm.zqrm_spmat_nrm_c(spmat::Ref{c_spmat{ComplexF64}}, ntype::Cchar, + nrm::Ptr{Cdouble})::Cint +end + +function zqrm_vecnrm_c(x, n, nrhs, ntype, nrm) + @ccall libzqrm.zqrm_vecnrm_c(x::Ptr{ComplexF64}, n::Cint, nrhs::Cint, ntype::Cchar, + nrm::Ptr{Cdouble})::Cint +end + +function zqrm_spbackslash_c(spmat, b, x, nrhs, transp) + @ccall libzqrm.zqrm_spbackslash_c(spmat::Ref{c_spmat{ComplexF64}}, b::Ptr{ComplexF64}, + x::Ptr{ComplexF64}, nrhs::Cint, transp::Cchar)::Cint +end + +function zqrm_spfct_backslash_c(spfct, b, x, nrhs, transp) + @ccall libzqrm.zqrm_spfct_backslash_c(spfct::Ref{c_spfct{ComplexF64}}, + b::Ptr{ComplexF64}, x::Ptr{ComplexF64}, + nrhs::Cint, transp::Cchar)::Cint +end + +function zqrm_spposv_c(spmat, b, x, nrhs) + @ccall libzqrm.zqrm_spposv_c(spmat::Ref{c_spmat{ComplexF64}}, b::Ptr{ComplexF64}, + x::Ptr{ComplexF64}, nrhs::Cint)::Cint +end + +function zqrm_least_squares_c(spmat, b, x, nrhs, transp) + @ccall libzqrm.zqrm_least_squares_c(spmat::Ref{c_spmat{ComplexF64}}, b::Ptr{ComplexF64}, + x::Ptr{ComplexF64}, nrhs::Cint, transp::Cchar)::Cint +end + +function zqrm_min_norm_c(spmat, b, x, nrhs, transp) + @ccall libzqrm.zqrm_min_norm_c(spmat::Ref{c_spmat{ComplexF64}}, b::Ptr{ComplexF64}, + x::Ptr{ComplexF64}, nrhs::Cint, transp::Cchar)::Cint +end + +function zqrm_residual_norm_c(spmat, b, x, nrhs, nrm, transp) + @ccall libzqrm.zqrm_residual_norm_c(spmat::Ref{c_spmat{ComplexF64}}, b::Ptr{ComplexF64}, + x::Ptr{ComplexF64}, nrhs::Cint, nrm::Ptr{Cdouble}, + transp::Cchar)::Cint +end + +function zqrm_residual_orth_c(spmat, r, nrhs, nrm, transp) + @ccall libzqrm.zqrm_residual_orth_c(spmat::Ref{c_spmat{ComplexF64}}, r::Ptr{ComplexF64}, + nrhs::Cint, nrm::Ptr{Cdouble}, transp::Cchar)::Cint +end + +function zqrm_spfct_trsm_c(spfct, transp, b, x, nrhs) + @ccall libzqrm.zqrm_spfct_trsm_c(spfct::Ref{c_spfct{ComplexF64}}, transp::Cchar, + b::Ptr{ComplexF64}, x::Ptr{ComplexF64}, + nrhs::Cint)::Cint +end + +function zqrm_spfct_sytrs_c(spfct, b, x, nrhs) + @ccall libzqrm.zqrm_spfct_sytrs_c(spfct::Ref{c_spfct{ComplexF64}}, b::Ptr{ComplexF64}, + x::Ptr{ComplexF64}, nrhs::Cint)::Cint +end + +function zqrm_spfct_set_i4_c(spfct, string, val) + @ccall libzqrm.zqrm_spfct_set_i4_c(spfct::Ref{c_spfct{ComplexF64}}, string::Cstring, + val::Cint)::Cint +end + +function zqrm_spfct_set_r4_c(spfct, string, val) + @ccall libzqrm.zqrm_spfct_set_r4_c(spfct::Ref{c_spfct{ComplexF64}}, string::Cstring, + val::Cfloat)::Cint +end + +function zqrm_spfct_get_i4_c(spfct, string, val) + @ccall libzqrm.zqrm_spfct_get_i4_c(spfct::Ref{c_spfct{ComplexF64}}, string::Cstring, + val::Ptr{Cint})::Cint +end + +function zqrm_spfct_get_r4_c(spfct, string, val) + @ccall libzqrm.zqrm_spfct_get_r4_c(spfct::Ref{c_spfct{ComplexF64}}, string::Cstring, + val::Ptr{Cfloat})::Cint +end + +function zqrm_spfct_get_i8_c(spfct, string, val) + @ccall libzqrm.zqrm_spfct_get_i8_c(spfct::Ref{c_spfct{ComplexF64}}, string::Cstring, + val::Ptr{Clonglong})::Cint +end + +function zqrm_spfct_get_schur_c(spfct, s, i, j, m, n) + @ccall libzqrm.zqrm_spfct_get_schur_c(spfct::Ref{c_spfct{ComplexF64}}, + s::Ptr{ComplexF64}, i::Cint, j::Cint, m::Cint, + n::Cint)::Cint +end + +function zqrm_spfct_get_r_c(spfct, spmat) + @ccall libzqrm.zqrm_spfct_get_r_c(spfct::Ref{c_spfct{ComplexF64}}, + spmat::Ref{c_spmat{ComplexF64}})::Cint +end + +function zqrm_spfct_get_cp_c(spfct, cp) + @ccall libzqrm.zqrm_spfct_get_cp_c(spfct::Ref{c_spfct{ComplexF64}}, + cp::Ptr{Ptr{Cint}})::Cint +end + +function zqrm_spfct_get_rp_c(spfct, rp) + @ccall libzqrm.zqrm_spfct_get_rp_c(spfct::Ref{c_spfct{ComplexF64}}, + rp::Ptr{Ptr{Cint}})::Cint +end + +function qrm_swtime() + @ccall libqrm_common.qrm_swtime()::Cdouble +end + +function qrm_glob_set_i4_c(string, val) + @ccall libqrm_common.qrm_glob_set_i4_c(string::Cstring, val::Cint)::Cint +end + +function qrm_glob_set_r4_c(string, val) + @ccall libqrm_common.qrm_glob_set_r4_c(string::Cstring, val::Cfloat)::Cint +end + +function qrm_glob_get_i4_c(string, val) + @ccall libqrm_common.qrm_glob_get_i4_c(string::Cstring, val::Ptr{Cint})::Cint +end + +function qrm_glob_get_r4_c(string, val) + @ccall libqrm_common.qrm_glob_get_r4_c(string::Cstring, val::Ptr{Cfloat})::Cint +end + +function qrm_glob_get_i8_c(string, val) + @ccall libqrm_common.qrm_glob_get_i8_c(string::Cstring, val::Ptr{Clonglong})::Cint +end + +function qrm_init_c(ncpu, ngpu) + @ccall libqrm_common.qrm_init_c(ncpu::Cint, ngpu::Cint)::Cint +end + +function qrm_finalize_c() + @ccall libqrm_common.qrm_finalize_c()::Cvoid +end diff --git a/src/wrapper/qr_mumps_api.jl b/src/wrapper/qr_mumps_api.jl index 21212c0..98938bf 100644 --- a/src/wrapper/qr_mumps_api.jl +++ b/src/wrapper/qr_mumps_api.jl @@ -1,11 +1,11 @@ -for (fname, lname, elty) in (("sqrm_spfct_get_rp_c", libsqrm, Float32 ), - ("dqrm_spfct_get_rp_c", libdqrm, Float64 ), - ("cqrm_spfct_get_rp_c", libcqrm, ComplexF32), - ("zqrm_spfct_get_rp_c", libzqrm, ComplexF64)) +for (fname, elty) in ((:sqrm_spfct_get_rp_c, :Float32 ), + (:dqrm_spfct_get_rp_c, :Float64 ), + (:cqrm_spfct_get_rp_c, :ComplexF32), + (:zqrm_spfct_get_rp_c, :ComplexF64)) @eval begin function qrm_spfct_get_rp(spfct :: qrm_spfct{$elty}) ptr_rp = Ref{Ptr{Cint}}() - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ptr{Ptr{Cint}}), spfct, ptr_rp) + err = $fname(spfct, ptr_rp) # Fix it with the release 3.0.5 # (err ≠ 0) && throw(ErrorException(error_handling(err))) rp = unsafe_wrap(Array, ptr_rp[], spfct.fct.m) @@ -14,14 +14,14 @@ for (fname, lname, elty) in (("sqrm_spfct_get_rp_c", libsqrm, Float32 ), end end -for (fname, lname, elty) in (("sqrm_spfct_get_cp_c", libsqrm, Float32 ), - ("dqrm_spfct_get_cp_c", libdqrm, Float64 ), - ("cqrm_spfct_get_cp_c", libcqrm, ComplexF32), - ("zqrm_spfct_get_cp_c", libzqrm, ComplexF64)) +for (fname, elty) in ((:sqrm_spfct_get_cp_c, :Float32 ), + (:dqrm_spfct_get_cp_c, :Float64 ), + (:cqrm_spfct_get_cp_c, :ComplexF32), + (:zqrm_spfct_get_cp_c, :ComplexF64)) @eval begin function qrm_spfct_get_cp(spfct :: qrm_spfct{$elty}) ptr_cp = Ref{Ptr{Cint}}() - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ptr{Ptr{Cint}}), spfct, ptr_cp) + err = $fname(spfct, ptr_cp) # Fix it with the release 3.0.5 # (err ≠ 0) && throw(ErrorException(error_handling(err))) cp = unsafe_wrap(Array, ptr_cp[], spfct.fct.n) @@ -30,14 +30,14 @@ for (fname, lname, elty) in (("sqrm_spfct_get_cp_c", libsqrm, Float32 ), end end -for (fname, lname, elty) in (("sqrm_spfct_get_r_c", libsqrm, Float32 ), - ("dqrm_spfct_get_r_c", libdqrm, Float64 ), - ("cqrm_spfct_get_r_c", libcqrm, ComplexF32), - ("zqrm_spfct_get_r_c", libzqrm, ComplexF64)) +for (fname, elty) in ((:sqrm_spfct_get_r_c, :Float32 ), + (:dqrm_spfct_get_r_c, :Float64 ), + (:cqrm_spfct_get_r_c, :ComplexF32), + (:zqrm_spfct_get_r_c, :ComplexF64)) @eval begin function qrm_spfct_get_r(spfct :: qrm_spfct{$elty}) spmat = qrm_spmat_init($elty) - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ref{c_spmat{$elty}}), spfct, spmat) + err = $fname(spfct, spmat) (err ≠ 0) && throw(ErrorException(error_handling(err))) I = unsafe_wrap(Array, spmat.mat.irn, spmat.mat.nz) J = unsafe_wrap(Array, spmat.mat.jcn, spmat.mat.nz) @@ -48,13 +48,13 @@ for (fname, lname, elty) in (("sqrm_spfct_get_r_c", libsqrm, Float32 ), end end -for (fname, lname, elty, subty) in (("sqrm_spmat_init_c", libsqrm, Float32 , Float32), - ("dqrm_spmat_init_c", libdqrm, Float64 , Float64), - ("cqrm_spmat_init_c", libcqrm, ComplexF32, Float32), - ("zqrm_spmat_init_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spmat_init_c, :Float32 ), + (:dqrm_spmat_init_c, :Float64 ), + (:cqrm_spmat_init_c, :ComplexF32), + (:zqrm_spmat_init_c, :ComplexF64)) @eval begin function qrm_spmat_init!(spmat :: qrm_spmat{$elty}) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}},), spmat) + err = $fname(spmat) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -69,7 +69,7 @@ for (fname, lname, elty, subty) in (("sqrm_spmat_init_c", libsqrm, Float32 , F nz = length(irn) @assert nz == length(jcn) @assert nz == length(val) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}},), spmat) + err = $fname(spmat) (err ≠ 0) && throw(ErrorException(error_handling(err))) spmat.irn = irn spmat.jcn = jcn @@ -108,26 +108,26 @@ for (fname, lname, elty, subty) in (("sqrm_spmat_init_c", libsqrm, Float32 , F end end -for (fname, lname, elty, subty) in (("sqrm_spmat_destroy_c", libsqrm, Float32 , Float32), - ("dqrm_spmat_destroy_c", libdqrm, Float64 , Float64), - ("cqrm_spmat_destroy_c", libcqrm, ComplexF32, Float32), - ("zqrm_spmat_destroy_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spmat_destroy_c, :Float32 ), + (:dqrm_spmat_destroy_c, :Float64 ), + (:cqrm_spmat_destroy_c, :ComplexF32), + (:zqrm_spmat_destroy_c, :ComplexF64)) @eval begin function qrm_spmat_destroy!(spmat :: qrm_spmat{$elty}) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}},), spmat) + err = $fname(spmat) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end end end -for (fname, lname, elty, subty) in (("sqrm_spfct_init_c", libsqrm, Float32 , Float32), - ("dqrm_spfct_init_c", libdqrm, Float64 , Float64), - ("cqrm_spfct_init_c", libcqrm, ComplexF32, Float32), - ("zqrm_spfct_init_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spfct_init_c, :Float32 ), + (:dqrm_spfct_init_c, :Float64 ), + (:cqrm_spfct_init_c, :ComplexF32), + (:zqrm_spfct_init_c, :ComplexF64)) @eval begin function qrm_spfct_init!(spfct :: qrm_spfct{$elty}, spmat :: qrm_spmat{$elty}) - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ref{c_spmat{$elty}}), spfct, spmat) + err = $fname(spfct, spmat) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -140,33 +140,33 @@ for (fname, lname, elty, subty) in (("sqrm_spfct_init_c", libsqrm, Float32 , F end end -for (fname, lname, elty, subty) in (("sqrm_spfct_destroy_c", libsqrm, Float32 , Float32), - ("dqrm_spfct_destroy_c", libdqrm, Float64 , Float64), - ("cqrm_spfct_destroy_c", libcqrm, ComplexF32, Float32), - ("zqrm_spfct_destroy_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spfct_destroy_c, :Float32 ), + (:dqrm_spfct_destroy_c, :Float64 ), + (:cqrm_spfct_destroy_c, :ComplexF32), + (:zqrm_spfct_destroy_c, :ComplexF64)) @eval begin function qrm_spfct_destroy!(spfct :: qrm_spfct{$elty}) - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}},), spfct) + err = $fname(spfct) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end end end -for (fname, lname, elty, subty) in (("sqrm_analyse_c", libsqrm, Float32 , Float32), - ("dqrm_analyse_c", libdqrm, Float64 , Float64), - ("cqrm_analyse_c", libcqrm, ComplexF32, Float32), - ("zqrm_analyse_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_analyse_c, :Float32 ), + (:dqrm_analyse_c, :Float64 ), + (:cqrm_analyse_c, :ComplexF32), + (:zqrm_analyse_c, :ComplexF64)) @eval begin function qrm_analyse!(spmat :: qrm_spmat{$elty}, spfct :: qrm_spfct{$elty}; transp :: Char='n') - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ref{c_spfct{$elty}}, UInt8), spmat, spfct, transp) + err = $fname(spmat, spfct, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end function qrm_analyse(spmat :: qrm_spmat{$elty}; transp :: Char='n') spfct = qrm_spfct_init(spmat) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ref{c_spfct{$elty}}, UInt8), spmat, spfct, transp) + err = $fname(spmat, spfct, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return spfct end @@ -179,13 +179,13 @@ for (fname, lname, elty, subty) in (("sqrm_analyse_c", libsqrm, Float32 , Floa end end -for (fname, lname, elty, subty) in (("sqrm_factorize_c", libsqrm, Float32 , Float32), - ("dqrm_factorize_c", libdqrm, Float64 , Float64), - ("cqrm_factorize_c", libcqrm, ComplexF32, Float32), - ("zqrm_factorize_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_factorize_c, :Float32 ), + (:dqrm_factorize_c, :Float64 ), + (:cqrm_factorize_c, :ComplexF32), + (:zqrm_factorize_c, :ComplexF64)) @eval begin function qrm_factorize!(spmat :: qrm_spmat{$elty}, spfct :: qrm_spfct{$elty}; transp :: Char='n') - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ref{c_spfct{$elty}}, UInt8), spmat, spfct, transp) + err = $fname(spmat, spfct, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -195,10 +195,10 @@ for (fname, lname, elty, subty) in (("sqrm_factorize_c", libsqrm, Float32 , Fl end end -for (fname, lname, elty, subty) in (("sqrm_solve_c", libsqrm, Float32 , Float32), - ("dqrm_solve_c", libdqrm, Float64 , Float64), - ("cqrm_solve_c", libcqrm, ComplexF32, Float32), - ("zqrm_solve_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_solve_c, :Float32 ), + (:dqrm_solve_c, :Float64 ), + (:cqrm_solve_c, :ComplexF32), + (:zqrm_solve_c, :ComplexF64)) @eval begin function qrm_solve!(spfct :: qrm_spfct{$elty}, b :: Vector{$elty}, x :: Vector{$elty}; transp :: Char='n') nrhs = 1 @@ -207,7 +207,7 @@ for (fname, lname, elty, subty) in (("sqrm_solve_c", libsqrm, Float32 , Float3 else @assert length(x) == spfct.fct.m end - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Ptr{$elty}, Cint), spfct, transp, b, x, nrhs) + err = $fname(spfct, transp, b, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -219,7 +219,7 @@ for (fname, lname, elty, subty) in (("sqrm_solve_c", libsqrm, Float32 , Float3 else @assert size(x) == (spfct.fct.m, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Ptr{$elty}, Cint), spfct, transp, b, x, nrhs) + err = $fname(spfct, transp, b, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -231,7 +231,7 @@ for (fname, lname, elty, subty) in (("sqrm_solve_c", libsqrm, Float32 , Float3 else x = zeros($elty, spfct.fct.m) end - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Ptr{$elty}, Cint), spfct, transp, b, x, nrhs) + err = $fname(spfct, transp, b, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -243,7 +243,7 @@ for (fname, lname, elty, subty) in (("sqrm_solve_c", libsqrm, Float32 , Float3 else x = zeros($elty, spfct.fct.m, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Ptr{$elty}, Cint), spfct, transp, b, x, nrhs) + err = $fname(spfct, transp, b, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -262,21 +262,21 @@ for (fname, lname, elty, subty) in (("sqrm_solve_c", libsqrm, Float32 , Float3 end end -for (fname, lname, elty, subty) in (("sqrm_apply_c", libsqrm, Float32 , Float32), - ("dqrm_apply_c", libdqrm, Float64 , Float64), - ("cqrm_apply_c", libcqrm, ComplexF32, Float32), - ("zqrm_apply_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_apply_c, :Float32 ), + (:dqrm_apply_c, :Float64 ), + (:cqrm_apply_c, :ComplexF32), + (:zqrm_apply_c, :ComplexF64)) @eval begin function qrm_apply!(spfct :: qrm_spfct{$elty}, b :: Vector{$elty}; transp :: Char='n') nrhs = 1 - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Cint), spfct, transp, b, nrhs) + err = $fname(spfct, transp, b, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end function qrm_apply!(spfct :: qrm_spfct{$elty}, b :: Matrix{$elty}; transp :: Char='n') nrhs = size(b, 2) - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Cint), spfct, transp, b, nrhs) + err = $fname(spfct, transp, b, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -284,7 +284,7 @@ for (fname, lname, elty, subty) in (("sqrm_apply_c", libsqrm, Float32 , Float3 function qrm_apply(spfct :: qrm_spfct{$elty}, b :: Vector{$elty}; transp :: Char='n') nrhs = 1 z = copy(b) - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Cint), spfct, transp, z, nrhs) + err = $fname(spfct, transp, z, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return z end @@ -292,7 +292,7 @@ for (fname, lname, elty, subty) in (("sqrm_apply_c", libsqrm, Float32 , Float3 function qrm_apply(spfct :: qrm_spfct{$elty}, b :: Matrix{$elty}; transp :: Char='n') nrhs = size(b, 2) z = copy(b) - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, UInt8, Ptr{$elty}, Cint), spfct, transp, z, nrhs) + err = $fname(spfct, transp, z, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return z end @@ -311,22 +311,21 @@ for (fname, lname, elty, subty) in (("sqrm_apply_c", libsqrm, Float32 , Float3 end end -# err is a Cvoid and not a Cint -for (fname, lname, elty, subty) in (("sqrm_spmat_mv_c", libsqrm, Float32 , Float32), - ("dqrm_spmat_mv_c", libdqrm, Float64 , Float64), - ("cqrm_spmat_mv_c", libcqrm, ComplexF32, Float32), - ("zqrm_spmat_mv_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spmat_mv_c, :Float32 ), + (:dqrm_spmat_mv_c, :Float64 ), + (:cqrm_spmat_mv_c, :ComplexF32), + (:zqrm_spmat_mv_c, :ComplexF64)) @eval begin function qrm_spmat_mv!(spmat :: qrm_spmat{$elty}, alpha :: $elty, x :: Vector{$elty}, beta :: $elty, y :: Vector{$elty}; transp :: Char='n') nrhs = 1 - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, UInt8, $elty, Ptr{$elty}, $elty, Ptr{$elty}, Cint), spmat, transp, alpha, x, beta, y, nrhs) + err = $fname(spmat, transp, alpha, x, beta, y, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end function qrm_spmat_mv!(spmat :: qrm_spmat{$elty}, alpha :: $elty, x :: Matrix{$elty}, beta :: $elty, y :: Matrix{$elty}; transp :: Char='n') nrhs = size(y, 2) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, UInt8, $elty, Ptr{$elty}, $elty, Ptr{$elty}, Cint), spmat, transp, alpha, x, beta, y, nrhs) + err = $fname(spmat, transp, alpha, x, beta, y, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -348,30 +347,30 @@ for (fname, lname, elty, subty) in (("sqrm_spmat_mv_c", libsqrm, Float32 , Flo end end -for (fname, lname, elty, subty) in (("sqrm_spmat_nrm_c", libsqrm, Float32 , Float32), - ("dqrm_spmat_nrm_c", libdqrm, Float64 , Float64), - ("cqrm_spmat_nrm_c", libcqrm, ComplexF32, Float32), - ("zqrm_spmat_nrm_c", libzqrm, ComplexF64, Float64)) +for (fname, elty, subty) in ((:sqrm_spmat_nrm_c, :Float32 , :Float32), + (:dqrm_spmat_nrm_c, :Float64 , :Float64), + (:cqrm_spmat_nrm_c, :ComplexF32, :Float32), + (:zqrm_spmat_nrm_c, :ComplexF64, :Float64)) @eval begin function qrm_spmat_nrm(spmat :: qrm_spmat{$elty}; ntype :: Char='f') nrm = Ref{$subty}(0) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, UInt8, Ref{$subty}), spmat, ntype, nrm) + err = $fname(spmat, ntype, nrm) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm[] end end end -for (fname, lname, elty, subty) in (("sqrm_vecnrm_c", libsqrm, Float32 , Float32), - ("dqrm_vecnrm_c", libdqrm, Float64 , Float64), - ("cqrm_vecnrm_c", libcqrm, ComplexF32, Float32), - ("zqrm_vecnrm_c", libzqrm, ComplexF64, Float64)) +for (fname, elty, subty) in ((:sqrm_vecnrm_c, :Float32 , :Float32), + (:dqrm_vecnrm_c, :Float64 , :Float64), + (:cqrm_vecnrm_c, :ComplexF32, :Float32), + (:zqrm_vecnrm_c, :ComplexF64, :Float64)) @eval begin function qrm_vecnrm(x :: Vector{$elty}; ntype :: Char='2') n = length(x) nrhs = 1 nrm = Ref{$subty}(0) - err = ccall(($fname, $lname), Cint, (Ptr{$elty}, Cint, Cint, UInt8, Ref{$subty}), x, n, nrhs, ntype, nrm) + err = $fname(x, n, nrhs, ntype, nrm) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm[] end @@ -379,24 +378,24 @@ for (fname, lname, elty, subty) in (("sqrm_vecnrm_c", libsqrm, Float32 , Float function qrm_vecnrm(x :: Matrix{$elty}; ntype :: Char='2') n, nrhs = size(x) nrm = zeros($subty, nrhs) - err = ccall(($fname, $lname), Cint, (Ptr{$elty}, Cint, Cint, UInt8, Ptr{$subty}), x, n, nrhs, ntype, nrm) + err = $fname(x, n, nrhs, ntype, nrm) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm end function qrm_vecnrm!(x :: Matrix{$elty}, nrm :: Vector{$subty}; ntype :: Char='2') n, nrhs = size(x) - err = ccall(($fname, $lname), Cint, (Ptr{$elty}, Cint, Cint, UInt8, Ptr{$subty}), x, n, nrhs, ntype, nrm) + err = $fname(x, n, nrhs, ntype, nrm) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end end end -for (fname, lname, elty, subty) in (("sqrm_spbackslash_c", libsqrm, Float32 , Float32), - ("dqrm_spbackslash_c", libdqrm, Float64 , Float64), - ("cqrm_spbackslash_c", libcqrm, ComplexF32, Float32), - ("zqrm_spbackslash_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spbackslash_c, :Float32 ), + (:dqrm_spbackslash_c, :Float64 ), + (:cqrm_spbackslash_c, :ComplexF32), + (:zqrm_spbackslash_c, :ComplexF64)) @eval begin function qrm_spbackslash!(spmat :: qrm_spmat{$elty}, b :: Vector{$elty}, x :: Vector{$elty}; transp :: Char='n') nrhs = 1 @@ -405,7 +404,7 @@ for (fname, lname, elty, subty) in (("sqrm_spbackslash_c", libsqrm, Float32 , else @assert length(x) == spmat.mat.m end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -417,7 +416,7 @@ for (fname, lname, elty, subty) in (("sqrm_spbackslash_c", libsqrm, Float32 , else @assert size(x) == (spmat.mat.m, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -431,7 +430,7 @@ for (fname, lname, elty, subty) in (("sqrm_spbackslash_c", libsqrm, Float32 , x = zeros($elty, spmat.mat.m) end bcopy = (spmat.mat.m ≥ spmat.mat.n) ? copy(b) : b - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, bcopy, x, nrhs, transp) + err = $fname(spmat, bcopy, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -444,7 +443,7 @@ for (fname, lname, elty, subty) in (("sqrm_spbackslash_c", libsqrm, Float32 , x = zeros($elty, spmat.mat.m, nrhs) end bcopy = (spmat.mat.m ≥ spmat.mat.n) ? copy(b) : b - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, bcopy, x, nrhs, transp) + err = $fname(spmat, bcopy, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -475,10 +474,10 @@ for (fname, lname, elty, subty) in (("sqrm_spbackslash_c", libsqrm, Float32 , end end -for (fname, lname, elty, subty) in (("sqrm_spfct_backslash_c", libsqrm, Float32 , Float32), - ("dqrm_spfct_backslash_c", libdqrm, Float64 , Float64), - ("cqrm_spfct_backslash_c", libcqrm, ComplexF32, Float32), - ("zqrm_spfct_backslash_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spfct_backslash_c, :Float32 ), + (:dqrm_spfct_backslash_c, :Float64 ), + (:cqrm_spfct_backslash_c, :ComplexF32), + (:zqrm_spfct_backslash_c, :ComplexF64)) @eval begin function qrm_spbackslash!(spfct :: qrm_spfct{$elty}, b :: Vector{$elty}, x :: Vector{$elty}; transp :: Char='n') nrhs = 1 @@ -487,7 +486,7 @@ for (fname, lname, elty, subty) in (("sqrm_spfct_backslash_c", libsqrm, Float32 else @assert length(x) == spfct.fct.m end - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spfct, b, x, nrhs, transp) + err = $fname(spfct, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -499,7 +498,7 @@ for (fname, lname, elty, subty) in (("sqrm_spfct_backslash_c", libsqrm, Float32 else @assert size(x) == (spfct.fct.m, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spfct, b, x, nrhs, transp) + err = $fname(spfct, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -513,7 +512,7 @@ for (fname, lname, elty, subty) in (("sqrm_spfct_backslash_c", libsqrm, Float32 x = zeros($elty, spfct.fct.m) end bcopy = (spfct.fct.m ≥ spfct.fct.n) ? copy(b) : b - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spfct, bcopy, x, nrhs, transp) + err = $fname(spfct, bcopy, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -526,7 +525,7 @@ for (fname, lname, elty, subty) in (("sqrm_spfct_backslash_c", libsqrm, Float32 x = zeros($elty, spfct.fct.m, nrhs) end bcopy = (spfct.fct.m ≥ spfct.fct.n) ? copy(b) : b - err = ccall(($fname, $lname), Cint, (Ref{c_spfct{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spfct, bcopy, x, nrhs, transp) + err = $fname(spfct, bcopy, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -555,21 +554,21 @@ for (fname, lname, elty, subty) in (("sqrm_spfct_backslash_c", libsqrm, Float32 end end -for (fname, lname, elty, subty) in (("sqrm_spposv_c", libsqrm, Float32 , Float32), - ("dqrm_spposv_c", libdqrm, Float64 , Float64), - ("cqrm_spposv_c", libcqrm, ComplexF32, Float32), - ("zqrm_spposv_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_spposv_c, :Float32 ), + (:dqrm_spposv_c, :Float64 ), + (:cqrm_spposv_c, :ComplexF32), + (:zqrm_spposv_c, :ComplexF64)) @eval begin function qrm_spposv!(spmat :: qrm_spmat{$elty}, b :: Vector{$elty}, x :: Vector{$elty}) nrhs = 1 - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint), spmat, b, x, nrhs) + err = $fname(spmat, b, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end function qrm_spposv!(spmat :: qrm_spmat{$elty}, b :: Matrix{$elty}, x :: Matrix{$elty}) nrhs = size(b, 2) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint), spmat, b, x, nrhs) + err = $fname(spmat, b, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -578,7 +577,7 @@ for (fname, lname, elty, subty) in (("sqrm_spposv_c", libsqrm, Float32 , Float nrhs = 1 x = zeros($elty, spmat.mat.n) bcopy = copy(b) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint), spmat, bcopy, x, nrhs) + err = $fname(spmat, bcopy, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -587,17 +586,17 @@ for (fname, lname, elty, subty) in (("sqrm_spposv_c", libsqrm, Float32 , Float nrhs = size(b, 2) x = zeros($elty, spmat.mat.n, nrhs) bcopy = copy(b) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint), spmat, bcopy, x, nrhs) + err = $fname(spmat, bcopy, x, nrhs) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end end end -for (fname, lname, elty, subty) in (("sqrm_least_squares_c", libsqrm, Float32 , Float32), - ("dqrm_least_squares_c", libdqrm, Float64 , Float64), - ("cqrm_least_squares_c", libcqrm, ComplexF32, Float32), - ("zqrm_least_squares_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_least_squares_c, :Float32 ), + (:dqrm_least_squares_c, :Float64 ), + (:cqrm_least_squares_c, :ComplexF32), + (:zqrm_least_squares_c, :ComplexF64)) @eval begin function qrm_least_squares!(spmat :: qrm_spmat{$elty}, b :: Vector{$elty}, x :: Vector{$elty}; transp :: Char='n') nrhs = 1 @@ -606,7 +605,7 @@ for (fname, lname, elty, subty) in (("sqrm_least_squares_c", libsqrm, Float32 else @assert length(x) == spmat.mat.m end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -618,7 +617,7 @@ for (fname, lname, elty, subty) in (("sqrm_least_squares_c", libsqrm, Float32 else @assert size(x) == (spmat.mat.m, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -631,7 +630,7 @@ for (fname, lname, elty, subty) in (("sqrm_least_squares_c", libsqrm, Float32 x = zeros($elty, spmat.mat.m) end bcopy = copy(b) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, bcopy, x, nrhs, transp) + err = $fname(spmat, bcopy, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -644,7 +643,7 @@ for (fname, lname, elty, subty) in (("sqrm_least_squares_c", libsqrm, Float32 x = zeros($elty, spmat.mat.n, nrhs) end bcopy = copy(b) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, bcopy, x, nrhs, transp) + err = $fname(spmat, bcopy, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -664,10 +663,10 @@ for (fname, lname, elty, subty) in (("sqrm_least_squares_c", libsqrm, Float32 end end -for (fname, lname, elty, subty) in (("sqrm_min_norm_c", libsqrm, Float32 , Float32), - ("dqrm_min_norm_c", libdqrm, Float64 , Float64), - ("cqrm_min_norm_c", libcqrm, ComplexF32, Float32), - ("zqrm_min_norm_c", libzqrm, ComplexF64, Float64)) +for (fname, elty) in ((:sqrm_min_norm_c, :Float32 ), + (:dqrm_min_norm_c, :Float64 ), + (:cqrm_min_norm_c, :ComplexF32), + (:zqrm_min_norm_c, :ComplexF64)) @eval begin function qrm_min_norm!(spmat :: qrm_spmat{$elty}, b :: Vector{$elty}, x :: Vector{$elty}; transp :: Char='n') nrhs = 1 @@ -676,7 +675,7 @@ for (fname, lname, elty, subty) in (("sqrm_min_norm_c", libsqrm, Float32 , Flo else @assert length(x) == spmat.mat.m end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -688,7 +687,7 @@ for (fname, lname, elty, subty) in (("sqrm_min_norm_c", libsqrm, Float32 , Flo else @assert size(x) == (spmat.mat.m, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -700,7 +699,7 @@ for (fname, lname, elty, subty) in (("sqrm_min_norm_c", libsqrm, Float32 , Flo else x = zeros($elty, spmat.mat.m) end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -712,7 +711,7 @@ for (fname, lname, elty, subty) in (("sqrm_min_norm_c", libsqrm, Float32 , Flo else x = zeros($elty, spmat.mat.n, nrhs) end - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, UInt8), spmat, b, x, nrhs, transp) + err = $fname(spmat, b, x, nrhs, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return x end @@ -732,15 +731,15 @@ for (fname, lname, elty, subty) in (("sqrm_min_norm_c", libsqrm, Float32 , Flo end end -for (fname, lname, elty, subty) in (("sqrm_residual_norm_c", libsqrm, Float32 , Float32), - ("dqrm_residual_norm_c", libdqrm, Float64 , Float64), - ("cqrm_residual_norm_c", libcqrm, ComplexF32, Float32), - ("zqrm_residual_norm_c", libzqrm, ComplexF64, Float64)) +for (fname, elty, subty) in ((:sqrm_residual_norm_c, :Float32 , :Float32), + (:dqrm_residual_norm_c, :Float64 , :Float64), + (:cqrm_residual_norm_c, :ComplexF32, :Float32), + (:zqrm_residual_norm_c, :ComplexF64, :Float64)) @eval begin function qrm_residual_norm(spmat :: qrm_spmat{$elty}, b :: Vector{$elty}, x :: Vector{$elty}; transp :: Char='n') nrhs = 1 nrm = Ref{$subty}(0) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, Ref{$subty}, UInt8), spmat, b, x, nrhs, nrm, transp) + err = $fname(spmat, b, x, nrhs, nrm, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm[] end @@ -748,14 +747,14 @@ for (fname, lname, elty, subty) in (("sqrm_residual_norm_c", libsqrm, Float32 function qrm_residual_norm(spmat :: qrm_spmat{$elty}, b :: Matrix{$elty}, x :: Matrix{$elty}; transp :: Char='n') nrhs = size(x, 2) nrm = zeros($subty, nrhs) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, Ptr{$subty}, UInt8), spmat, b, x, nrhs, nrm, transp) + err = $fname(spmat, b, x, nrhs, nrm, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm end function qrm_residual_norm!(spmat :: qrm_spmat{$elty}, b :: Matrix{$elty}, x :: Matrix{$elty}, nrm :: Vector{$subty}; transp :: Char='n') nrhs = size(x, 2) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Ptr{$elty}, Cint, Ptr{$subty}, UInt8), spmat, b, x, nrhs, nrm, transp) + err = $fname(spmat, b, x, nrhs, nrm, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -773,15 +772,15 @@ for (fname, lname, elty, subty) in (("sqrm_residual_norm_c", libsqrm, Float32 end end -for (fname, lname, elty, subty) in (("sqrm_residual_orth_c", libsqrm, Float32 , Float32), - ("dqrm_residual_orth_c", libdqrm, Float64 , Float64), - ("cqrm_residual_orth_c", libcqrm, ComplexF32, Float32), - ("zqrm_residual_orth_c", libzqrm, ComplexF64, Float64)) +for (fname, elty, subty) in ((:sqrm_residual_orth_c, :Float32 , :Float32), + (:dqrm_residual_orth_c, :Float64 , :Float64), + (:cqrm_residual_orth_c, :ComplexF32, :Float32), + (:zqrm_residual_orth_c, :ComplexF64, :Float64)) @eval begin function qrm_residual_orth(spmat :: qrm_spmat{$elty}, r :: Vector{$elty}; transp :: Char='n') nrhs = 1 nrm = Ref{$subty}(0) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Cint, Ref{$subty}, UInt8), spmat, r, nrhs, nrm, transp) + err = $fname(spmat, r, nrhs, nrm, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm[] end @@ -789,14 +788,14 @@ for (fname, lname, elty, subty) in (("sqrm_residual_orth_c", libsqrm, Float32 function qrm_residual_orth(spmat :: qrm_spmat{$elty}, r :: Matrix{$elty}; transp :: Char='n') nrhs = size(r, 2) nrm = zeros($subty, nrhs) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Cint, Ptr{$subty}, UInt8), spmat, r, nrhs, nrm, transp) + err = $fname(spmat, r, nrhs, nrm, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nrm end function qrm_residual_orth!(spmat :: qrm_spmat{$elty}, r :: Matrix{$elty}, nrm :: Vector{$subty}; transp :: Char='n') nrhs = size(r, 2) - err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}}, Ptr{$elty}, Cint, Ptr{$subty}, UInt8), spmat, r, nrhs, nrm, transp) + err = $fname(spmat, r, nrhs, nrm, transp) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end @@ -814,9 +813,9 @@ end function qrm_set(str :: String, val :: Number) if (str ∈ GICNTL) || (str ∈ PICNTL) - err = ccall(("qrm_glob_set_i4_c", libqrm_common), Cint, (Cstring, Cint), str, val) + err = qrm_glob_set_i4_c(str, val) elseif str ∈ RCNTL - err = ccall(("qrm_glob_set_r4_c", libqrm_common), Cint, (Cstring, Cfloat), str, val) + err = qrm_glob_set_r4_c(str, val) else err = Int32(23) end @@ -824,16 +823,16 @@ function qrm_set(str :: String, val :: Number) return nothing end -for (finame, frname, lname, elty, subty) in (("sqrm_spfct_set_i4_c", "sqrm_spfct_set_r4_c", libsqrm, Float32 , Float32), - ("dqrm_spfct_set_i4_c", "dqrm_spfct_set_r4_c", libdqrm, Float64 , Float64), - ("cqrm_spfct_set_i4_c", "cqrm_spfct_set_r4_c", libcqrm, ComplexF32, Float32), - ("zqrm_spfct_set_i4_c", "zqrm_spfct_set_r4_c", libzqrm, ComplexF64, Float64)) +for (finame, frname, elty) in ((:sqrm_spfct_set_i4_c, :sqrm_spfct_set_r4_c, :Float32 ), + (:dqrm_spfct_set_i4_c, :dqrm_spfct_set_r4_c, :Float64 ), + (:cqrm_spfct_set_i4_c, :cqrm_spfct_set_r4_c, :ComplexF32), + (:zqrm_spfct_set_i4_c, :zqrm_spfct_set_r4_c, :ComplexF64)) @eval begin function qrm_set(spfct :: qrm_spfct{$elty}, str :: String, val :: Number) if str ∈ PICNTL - err = ccall(($finame, $lname), Cint, (Ref{c_spfct{$elty}}, Cstring, Cint), spfct, str, val) + err = $finame(spfct, str, val) elseif str ∈ RCNTL - err = ccall(($frname, $lname), Cint, (Ref{c_spfct{$elty}}, Cstring, Cfloat), spfct, str, val) + err = $frname(spfct, str, val) else err = Int32(23) end @@ -846,10 +845,10 @@ end function qrm_get(str :: String) if (str ∈ GICNTL) || (str ∈ PICNTL) val = Ref{Clonglong}(0) - err = ccall(("qrm_glob_get_i8_c", libqrm_common), Cint, (Cstring, Ref{Clonglong}), str, val) + err = qrm_glob_get_i8_c(str, val) elseif str ∈ RCNTL val = Ref{Float32}(0) - err = ccall(("qrm_glob_get_r4_c", libqrm_common), Cint, (Cstring, Ref{Cfloat}), str, val) + err = qrm_glob_get_r4_c(str, val) else err = Int32(23) end @@ -857,18 +856,18 @@ function qrm_get(str :: String) return val[] end -for (finame, frname, lname, elty, subty) in (("sqrm_spfct_get_i8_c", "sqrm_spfct_get_r4_c", libsqrm, Float32 , Float32), - ("dqrm_spfct_get_i8_c", "dqrm_spfct_get_r4_c", libdqrm, Float64 , Float64), - ("cqrm_spfct_get_i8_c", "cqrm_spfct_get_r4_c", libcqrm, ComplexF32, Float32), - ("zqrm_spfct_get_i8_c", "zqrm_spfct_get_r4_c", libzqrm, ComplexF64, Float64)) +for (finame, frname, elty) in ((:sqrm_spfct_get_i8_c, :sqrm_spfct_get_r4_c, :Float32 ), + (:dqrm_spfct_get_i8_c, :dqrm_spfct_get_r4_c, :Float64 ), + (:cqrm_spfct_get_i8_c, :cqrm_spfct_get_r4_c, :ComplexF32), + (:zqrm_spfct_get_i8_c, :zqrm_spfct_get_r4_c, :ComplexF64)) @eval begin function qrm_get(spfct :: qrm_spfct{$elty}, str :: String) if (str ∈ PICNTL) || (str ∈ STATS) val = Ref{Clonglong}(0) - err = ccall(($finame, $lname), Cint, (Ref{c_spfct{$elty}}, Cstring, Ref{Clonglong}), spfct, str, val) + err = $finame(spfct, str, val) elseif str ∈ RCNTL val = Ref{Float32}(0) - err = ccall(($frname, $lname), Cint, (Ref{c_spfct{$elty}}, Cstring, Ref{Cfloat}), spfct, str, val) + err = $frname(spfct, str, val) else err = Int32(23) end @@ -878,15 +877,14 @@ for (finame, frname, lname, elty, subty) in (("sqrm_spfct_get_i8_c", "sqrm_spfct end end -function qrm_init(ncpu :: Integer=1, ngpu :: Integer=0) - err = ccall(("qrm_init_c", libqrm_common), Cint, (Cint, Cint), ncpu, ngpu) +function qrm_init(ncpu :: Integer = 1, ngpu :: Integer = 0) + err = qrm_init_c(ncpu, ngpu) (err ≠ 0) && throw(ErrorException(error_handling(err))) return nothing end function qrm_finalize() - ccall(("qrm_finalize_c", libqrm_common), Cvoid, ()) - return nothing + qrm_finalize_c() end function qrm_update!(spmat :: qrm_spmat{T}, val :: AbstractVector{T}) where T diff --git a/test/test_qrm.jl b/test/test_qrm.jl index 020e2dc..4803744 100644 --- a/test/test_qrm.jl +++ b/test/test_qrm.jl @@ -452,7 +452,7 @@ end qrm_set(str, 1) end - for T in (Float32, Float64, ComplexF32, ComplexF64) + @testset "precision = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) transp = (T <: Real) ? 't' : 'c' A = sprand(T, n, n, 0.3) spmat = qrm_spmat_init(A)