diff --git a/Project.toml b/Project.toml index 3a06c63..50d9bd5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "HSL" uuid = "34c5aeac-e683-54a6-a0e9-6e0fdc586c50" -version = "0.4.3" +version = "0.5.0" [deps] HSL_jll = "017b0a0e-03f4-516a-9b91-836bbd1904dd" diff --git a/gen/rewriter.jl b/gen/rewriter.jl index 3858c68..3b89303 100644 --- a/gen/rewriter.jl +++ b/gen/rewriter.jl @@ -158,6 +158,8 @@ function hsl_subset_rewrite!(path::String, name::String, optimized::Bool) routine = code * "end\n" if name == "hsl_mc68" endswith(fname, "_i") || error("The symbol $fname should have the suffix _i") + pp_fname = replace(pp_fname, "control_d" => "control_i") + pp_fname = replace(pp_fname, "order_d" => "order_i") routine = replace(routine, "function $fname(" => "function $(fname_generic)(::Type{$ipc_}, ") else endswith(fname, "_d") || error("The symbol $fname should have the suffix _d") @@ -191,11 +193,30 @@ function hsl_subset_rewrite!(path::String, name::String, optimized::Bool) structure = replace(structure, "ipc_" => "INT") if !contains(code, "rpc_") structure = replace(structure, structure_name => generic_structure_name * "{INT}") + types = "{INT}" push!(info_structures, (structure_name, generic_structure_name, false)) else structure = replace(structure, structure_name => generic_structure_name * "{T,INT}") + types = "{T,INT}" push!(info_structures, (structure_name, generic_structure_name, true)) end + + # Add two constructors for each structure + arguments = "" + lines = split(code, "\n", keepempty=false) + for line in lines + if contains(line, "::") + argument = split(line, "::")[1][3:end] + if arguments == "" + arguments *= argument + else + arguments *= ", $argument" + end + end + end + structure = replace(structure, "end\n" => "\n " * generic_structure_name * "$types() where $types = new$types()\nend\n") + structure = replace(structure, "end\n" => "\n " * generic_structure_name * "$types($arguments) where $types = new$types($arguments)\nend\n") + structures = structures * structure * "\n" else text = text * code diff --git a/src/C/hsl_subset/hsl_ma48.jl b/src/C/hsl_subset/hsl_ma48.jl index 75cfd7c..6af0694 100644 --- a/src/C/hsl_subset/hsl_ma48.jl +++ b/src/C/hsl_subset/hsl_ma48.jl @@ -19,6 +19,16 @@ mutable struct Ma48Control{T, INT} diagonal_pivoting::INT fill_in::INT switch_mode::INT + + Ma48Control{T, INT}() where {T,INT} = new{T, INT}() + + function Ma48Control{T, INT}(f_arrays, multiplier, u, switch_, drop, tolerance, cgce, lp, wp, mp, + ldiag, btf, struct_, maxit, factor_blocking, solve_blas, pivoting, + diagonal_pivoting, fill_in, switch_mode) where {T,INT} + return new{T, INT}(f_arrays, multiplier, u, switch_, drop, tolerance, cgce, lp, wp, mp, ldiag, + btf, struct_, maxit, factor_blocking, solve_blas, pivoting, + diagonal_pivoting, fill_in, switch_mode) + end end mutable struct Ma48Ainfo{T, INT} @@ -39,6 +49,15 @@ mutable struct Ma48Ainfo{T, INT} lblock::INT sblock::INT tblock::Int64 + + Ma48Ainfo{T, INT}() where {T,INT} = new{T, INT}() + + function Ma48Ainfo{T, INT}(ops, flag, more, lena_analyse, lenj_analyse, lena_factorize, + leni_factorize, ncmpa, rank, drop, struc_rank, oor, dup, stat, lblock, + sblock, tblock) where {T,INT} + return new{T, INT}(ops, flag, more, lena_analyse, lenj_analyse, lena_factorize, leni_factorize, + ncmpa, rank, drop, struc_rank, oor, dup, stat, lblock, sblock, tblock) + end end mutable struct Ma48Finfo{T, INT} @@ -51,12 +70,24 @@ mutable struct Ma48Finfo{T, INT} drop::Int64 rank::INT stat::INT + + Ma48Finfo{T, INT}() where {T,INT} = new{T, INT}() + + function Ma48Finfo{T, INT}(ops, flag, more, size_factor, lena_factorize, leni_factorize, drop, + rank, stat) where {T,INT} + return new{T, INT}(ops, flag, more, size_factor, lena_factorize, leni_factorize, drop, rank, + stat) + end end mutable struct Ma48Sinfo{INT} flag::INT more::INT stat::INT + + Ma48Sinfo{INT}() where {INT} = new{INT}() + + Ma48Sinfo{INT}(flag, more, stat) where {INT} = new{INT}(flag, more, stat) end function ma48_initialize(::Type{Float32}, ::Type{Int32}, factors) diff --git a/src/C/hsl_subset/hsl_ma57.jl b/src/C/hsl_subset/hsl_ma57.jl index 051089f..3ba5f21 100644 --- a/src/C/hsl_subset/hsl_ma57.jl +++ b/src/C/hsl_subset/hsl_ma57.jl @@ -27,6 +27,19 @@ mutable struct Ma57Control{T, INT} rank_deficient::INT ispare::NTuple{5, INT} rspare::NTuple{10, T} + + Ma57Control{T, INT}() where {T,INT} = new{T, INT}() + + function Ma57Control{T, INT}(f_arrays, multiplier, reduce, u, static_tolerance, static_level, + tolerance, convergence, consist, lp, wp, mp, sp, ldiag, nemin, + factorblocking, solveblocking, la, liw, maxla, maxliw, pivoting, + thresh, ordering, scaling, rank_deficient, ispare, + rspare) where {T,INT} + return new{T, INT}(f_arrays, multiplier, reduce, u, static_tolerance, static_level, tolerance, + convergence, consist, lp, wp, mp, sp, ldiag, nemin, factorblocking, + solveblocking, la, liw, maxla, maxliw, pivoting, thresh, ordering, scaling, + rank_deficient, ispare, rspare) + end end mutable struct Ma57Ainfo{T, INT} @@ -49,6 +62,15 @@ mutable struct Ma57Ainfo{T, INT} stat::INT ispare::NTuple{5, INT} rspare::NTuple{10, T} + + Ma57Ainfo{T, INT}() where {T,INT} = new{T, INT}() + + function Ma57Ainfo{T, INT}(opsa, opse, flag, more, nsteps, nrltot, nirtot, nrlnec, nirnec, nrladu, + niradu, ncmpa, ordering, oor, dup, maxfrt, stat, ispare, + rspare) where {T,INT} + return new{T, INT}(opsa, opse, flag, more, nsteps, nrltot, nirtot, nrlnec, nirnec, nrladu, + niradu, ncmpa, ordering, oor, dup, maxfrt, stat, ispare, rspare) + end end mutable struct Ma57Finfo{T, INT} @@ -80,6 +102,17 @@ mutable struct Ma57Finfo{T, INT} stat::INT ispare::NTuple{5, INT} rspare::NTuple{10, T} + + Ma57Finfo{T, INT}() where {T,INT} = new{T, INT}() + + function Ma57Finfo{T, INT}(opsa, opse, opsb, maxchange, smin, smax, flag, more, maxfrt, nebdu, + nrlbdu, nirbdu, nrltot, nirtot, nrlnec, nirnec, ncmpbr, ncmpbi, ntwo, + neig, delay, signc, static_, modstep, rank, stat, ispare, + rspare) where {T,INT} + return new{T, INT}(opsa, opse, opsb, maxchange, smin, smax, flag, more, maxfrt, nebdu, nrlbdu, + nirbdu, nrltot, nirtot, nrlnec, nirnec, ncmpbr, ncmpbi, ntwo, neig, delay, + signc, static_, modstep, rank, stat, ispare, rspare) + end end mutable struct Ma57Sinfo{T, INT} @@ -92,6 +125,13 @@ mutable struct Ma57Sinfo{T, INT} stat::INT ispare::NTuple{5, INT} rspare::NTuple{10, T} + + Ma57Sinfo{T, INT}() where {T,INT} = new{T, INT}() + + function Ma57Sinfo{T, INT}(cond, cond2, berr, berr2, error, flag, stat, ispare, + rspare) where {T,INT} + return new{T, INT}(cond, cond2, berr, berr2, error, flag, stat, ispare, rspare) + end end function ma57_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_ma77.jl b/src/C/hsl_subset/hsl_ma77.jl index 15971cd..e648aaa 100644 --- a/src/C/hsl_subset/hsl_ma77.jl +++ b/src/C/hsl_subset/hsl_ma77.jl @@ -28,6 +28,19 @@ mutable struct Ma77Control{T, INT} ispare::NTuple{5, INT} lspare::NTuple{5, Int64} rspare::NTuple{5, T} + + Ma77Control{T, INT}() where {T,INT} = new{T, INT}() + + function Ma77Control{T, INT}(f_arrays, print_level, unit_diagnostics, unit_error, unit_warning, + bits, buffer_lpage, buffer_npage, file_size, maxstore, storage, + nemin, maxit, infnorm, thresh, nb54, action, multiplier, nb64, nbi, + small, static_, storage_indef, u, umin, consist_tol, ispare, lspare, + rspare) where {T,INT} + return new{T, INT}(f_arrays, print_level, unit_diagnostics, unit_error, unit_warning, bits, + buffer_lpage, buffer_npage, file_size, maxstore, storage, nemin, maxit, + infnorm, thresh, nb54, action, multiplier, nb64, nbi, small, static_, + storage_indef, u, umin, consist_tol, ispare, lspare, rspare) + end end mutable struct Ma77Info{T, INT} @@ -65,6 +78,20 @@ mutable struct Ma77Info{T, INT} ispare::NTuple{5, INT} lspare::NTuple{5, Int64} rspare::NTuple{5, T} + + Ma77Info{T, INT}() where {T,INT} = new{T, INT}() + + function Ma77Info{T, INT}(detlog, detsign, flag, iostat, matrix_dup, matrix_rank, matrix_outrange, + maxdepth, maxfront, minstore, ndelay, nfactor, nflops, niter, nsup, + num_neg, num_nothresh, num_perturbed, ntwo, stat, index, nio_read, + nio_write, nwd_read, nwd_write, num_file, storage, tree_nodes, + unit_restart, unused, usmall, ispare, lspare, rspare) where {T,INT} + return new{T, INT}(detlog, detsign, flag, iostat, matrix_dup, matrix_rank, matrix_outrange, + maxdepth, maxfront, minstore, ndelay, nfactor, nflops, niter, nsup, num_neg, + num_nothresh, num_perturbed, ntwo, stat, index, nio_read, nio_write, + nwd_read, nwd_write, num_file, storage, tree_nodes, unit_restart, unused, + usmall, ispare, lspare, rspare) + end end function ma77_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_ma86.jl b/src/C/hsl_subset/hsl_ma86.jl index 2b16f1c..f897459 100644 --- a/src/C/hsl_subset/hsl_ma86.jl +++ b/src/C/hsl_subset/hsl_ma86.jl @@ -14,6 +14,15 @@ mutable struct Ma86Control{T, INT} u::T umin::T scaling::INT + + Ma86Control{T, INT}() where {T,INT} = new{T, INT}() + + function Ma86Control{T, INT}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, + unit_warning, nemin, nb, action, nbi, pool_size, small_, static_, u, + umin, scaling) where {T,INT} + return new{T, INT}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, + nemin, nb, action, nbi, pool_size, small_, static_, u, umin, scaling) + end end mutable struct Ma86Info{T, INT} @@ -33,6 +42,16 @@ mutable struct Ma86Info{T, INT} pool_size::INT stat::INT usmall::T + + Ma86Info{T, INT}() where {T,INT} = new{T, INT}() + + function Ma86Info{T, INT}(detlog, detsign, flag, matrix_rank, maxdepth, num_delay, num_factor, + num_flops, num_neg, num_nodes, num_nothresh, num_perturbed, num_two, + pool_size, stat, usmall) where {T,INT} + return new{T, INT}(detlog, detsign, flag, matrix_rank, maxdepth, num_delay, num_factor, + num_flops, num_neg, num_nodes, num_nothresh, num_perturbed, num_two, + pool_size, stat, usmall) + end end function ma86_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_ma87.jl b/src/C/hsl_subset/hsl_ma87.jl index 8477f5f..e95021c 100644 --- a/src/C/hsl_subset/hsl_ma87.jl +++ b/src/C/hsl_subset/hsl_ma87.jl @@ -10,6 +10,15 @@ mutable struct Ma87Control{T, INT} diag_zero_minus::T diag_zero_plus::T unused::NTuple{40, Cchar} + + Ma87Control{T, INT}() where {T,INT} = new{T, INT}() + + function Ma87Control{T, INT}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, + unit_warning, nemin, nb, pool_size, diag_zero_minus, diag_zero_plus, + unused) where {T,INT} + return new{T, INT}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, + nemin, nb, pool_size, diag_zero_minus, diag_zero_plus, unused) + end end mutable struct Ma87Info{T, INT} @@ -23,6 +32,14 @@ mutable struct Ma87Info{T, INT} stat::INT num_zero::INT unused::NTuple{40, Cchar} + + Ma87Info{T, INT}() where {T,INT} = new{T, INT}() + + function Ma87Info{T, INT}(detlog, flag, maxdepth, num_factor, num_flops, num_nodes, pool_size, + stat, num_zero, unused) where {T,INT} + return new{T, INT}(detlog, flag, maxdepth, num_factor, num_flops, num_nodes, pool_size, stat, + num_zero, unused) + end end function ma87_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_ma97.jl b/src/C/hsl_subset/hsl_ma97.jl index 9443750..bc46aeb 100644 --- a/src/C/hsl_subset/hsl_ma97.jl +++ b/src/C/hsl_subset/hsl_ma97.jl @@ -18,6 +18,17 @@ mutable struct Ma97Control{T, INT} consist_tol::T ispare::NTuple{5, INT} rspare::NTuple{10, T} + + Ma97Control{T, INT}() where {T,INT} = new{T, INT}() + + function Ma97Control{T, INT}(f_arrays, action, nemin, multiplier, ordering, print_level, scaling, + small, u, unit_diagnostics, unit_error, unit_warning, factor_min, + solve_blas3, solve_min, solve_mf, consist_tol, ispare, + rspare) where {T,INT} + return new{T, INT}(f_arrays, action, nemin, multiplier, ordering, print_level, scaling, small, + u, unit_diagnostics, unit_error, unit_warning, factor_min, solve_blas3, + solve_min, solve_mf, consist_tol, ispare, rspare) + end end mutable struct Ma97Info{T, INT} @@ -41,6 +52,17 @@ mutable struct Ma97Info{T, INT} maxsupernode::INT ispare::NTuple{4, INT} rspare::NTuple{10, T} + + Ma97Info{T, INT}() where {T,INT} = new{T, INT}() + + function Ma97Info{T, INT}(flag, flag68, flag77, matrix_dup, matrix_rank, matrix_outrange, + matrix_missing_diag, maxdepth, maxfront, num_delay, num_factor, + num_flops, num_neg, num_sup, num_two, ordering, stat, maxsupernode, + ispare, rspare) where {T,INT} + return new{T, INT}(flag, flag68, flag77, matrix_dup, matrix_rank, matrix_outrange, + matrix_missing_diag, maxdepth, maxfront, num_delay, num_factor, num_flops, + num_neg, num_sup, num_two, ordering, stat, maxsupernode, ispare, rspare) + end end function ma97_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_mc64.jl b/src/C/hsl_subset/hsl_mc64.jl index 1dd8563..016ce67 100644 --- a/src/C/hsl_subset/hsl_mc64.jl +++ b/src/C/hsl_subset/hsl_mc64.jl @@ -5,6 +5,12 @@ mutable struct Mc64Control{INT} sp::INT ldiag::INT checking::INT + + Mc64Control{INT}() where {INT} = new{INT}() + + function Mc64Control{INT}(f_arrays, lp, wp, sp, ldiag, checking) where {INT} + return new{INT}(f_arrays, lp, wp, sp, ldiag, checking) + end end mutable struct Mc64Info{INT} @@ -12,6 +18,10 @@ mutable struct Mc64Info{INT} more::INT strucrank::INT stat::INT + + Mc64Info{INT}() where {INT} = new{INT}() + + Mc64Info{INT}(flag, more, strucrank, stat) where {INT} = new{INT}(flag, more, strucrank, stat) end function mc64_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_mc68.jl b/src/C/hsl_subset/hsl_mc68.jl index f2001e9..7254d1a 100644 --- a/src/C/hsl_subset/hsl_mc68.jl +++ b/src/C/hsl_subset/hsl_mc68.jl @@ -9,6 +9,14 @@ mutable struct Mc68Control{INT} print_level::INT row_full_thresh::INT row_search::INT + + Mc68Control{INT}() where {INT} = new{INT}() + + function Mc68Control{INT}(f_array_in, f_array_out, min_l_workspace, lp, wp, mp, nemin, + print_level, row_full_thresh, row_search) where {INT} + return new{INT}(f_array_in, f_array_out, min_l_workspace, lp, wp, mp, nemin, print_level, + row_full_thresh, row_search) + end end mutable struct Mc68Info{INT} @@ -22,25 +30,33 @@ mutable struct Mc68Info{INT} l_workspace::Int64 zb01_info::INT n_dense_rows::INT + + Mc68Info{INT}() where {INT} = new{INT}() + + function Mc68Info{INT}(flag, iostat, stat, out_range, duplicate, n_compressions, n_zero_eigs, + l_workspace, zb01_info, n_dense_rows) where {INT} + return new{INT}(flag, iostat, stat, out_range, duplicate, n_compressions, n_zero_eigs, + l_workspace, zb01_info, n_dense_rows) + end end function mc68_default_control(::Type{Int32}, control) - @ccall libhsl_subset.mc68_default_control_d(control::Ref{Mc68Control{Int32}})::Cvoid + @ccall libhsl_subset.mc68_default_control_i(control::Ref{Mc68Control{Int32}})::Cvoid end function mc68_default_control(::Type{Int64}, control) - @ccall libhsl_subset_64.mc68_default_control_d_64(control::Ref{Mc68Control{Int64}})::Cvoid + @ccall libhsl_subset_64.mc68_default_control_i_64(control::Ref{Mc68Control{Int64}})::Cvoid end function mc68_order(::Type{Int32}, ord, n, ptr, row, perm, control, info) - @ccall libhsl_subset.mc68_order_d(ord::Int32, n::Int32, ptr::Ptr{Int32}, row::Ptr{Int32}, + @ccall libhsl_subset.mc68_order_i(ord::Int32, n::Int32, ptr::Ptr{Int32}, row::Ptr{Int32}, perm::Ptr{Int32}, control::Ref{Mc68Control{Int32}}, info::Ref{Mc68Info{Int32}})::Cvoid end function mc68_order(::Type{Int64}, ord, n, ptr, row, perm, control, info) - @ccall libhsl_subset_64.mc68_order_d_64(ord::Int64, n::Int64, ptr::Ptr{Int64}, row::Ptr{Int64}, + @ccall libhsl_subset_64.mc68_order_i_64(ord::Int64, n::Int64, ptr::Ptr{Int64}, row::Ptr{Int64}, perm::Ptr{Int64}, control::Ref{Mc68Control{Int64}}, info::Ref{Mc68Info{Int64}})::Cvoid diff --git a/src/C/hsl_subset/hsl_mi20.jl b/src/C/hsl_subset/hsl_mi20.jl index 95ca3ba..daf12e2 100644 --- a/src/C/hsl_subset/hsl_mi20.jl +++ b/src/C/hsl_subset/hsl_mi20.jl @@ -22,6 +22,19 @@ mutable struct Mi20Control{T, INT} print::INT error::INT one_pass_coarsen::INT + + Mi20Control{T, INT}() where {T,INT} = new{T, INT}() + + function Mi20Control{T, INT}(f_arrays, aggressive, c_fail, max_levels, max_points, reduction, + st_method, st_parameter, testing, trunc_parameter, coarse_solver, + coarse_solver_its, damping, err_tol, levels, pre_smoothing, smoother, + post_smoothing, v_iterations, print_level, print, error, + one_pass_coarsen) where {T,INT} + return new{T, INT}(f_arrays, aggressive, c_fail, max_levels, max_points, reduction, st_method, + st_parameter, testing, trunc_parameter, coarse_solver, coarse_solver_its, + damping, err_tol, levels, pre_smoothing, smoother, post_smoothing, + v_iterations, print_level, print, error, one_pass_coarsen) + end end mutable struct Mi20SolveControl{T, INT} @@ -33,6 +46,15 @@ mutable struct Mi20SolveControl{T, INT} max_its::INT preconditioner_side::INT rel_tol::T + + Mi20SolveControl{T, INT}() where {T,INT} = new{T, INT}() + + function Mi20SolveControl{T, INT}(abs_tol, breakdown_tol, gmres_restart, init_guess, + krylov_solver, max_its, preconditioner_side, + rel_tol) where {T,INT} + return new{T, INT}(abs_tol, breakdown_tol, gmres_restart, init_guess, krylov_solver, max_its, + preconditioner_side, rel_tol) + end end mutable struct Mi20Info{T, INT} @@ -44,6 +66,13 @@ mutable struct Mi20Info{T, INT} getrf_info::INT iterations::INT residual::T + + Mi20Info{T, INT}() where {T,INT} = new{T, INT}() + + function Mi20Info{T, INT}(flag, clevels, cpoints, cnnz, stat, getrf_info, iterations, + residual) where {T,INT} + return new{T, INT}(flag, clevels, cpoints, cnnz, stat, getrf_info, iterations, residual) + end end function mi20_default_control(::Type{Float32}, ::Type{Int32}, control) diff --git a/src/C/hsl_subset/hsl_mi28.jl b/src/C/hsl_subset/hsl_mi28.jl index 746b293..95b181d 100644 --- a/src/C/hsl_subset/hsl_mi28.jl +++ b/src/C/hsl_subset/hsl_mi28.jl @@ -14,6 +14,15 @@ mutable struct Mi28Control{T, INT} tau2::T unit_error::INT unit_warning::INT + + Mi28Control{T, INT}() where {T,INT} = new{T, INT}() + + function Mi28Control{T, INT}(f_arrays, alpha, check, iorder, iscale, lowalpha, maxshift, rrt, + shift_factor, shift_factor2, small, tau1, tau2, unit_error, + unit_warning) where {T,INT} + return new{T, INT}(f_arrays, alpha, check, iorder, iscale, lowalpha, maxshift, rrt, + shift_factor, shift_factor2, small, tau1, tau2, unit_error, unit_warning) + end end mutable struct Mi28Info{T, INT} @@ -33,6 +42,15 @@ mutable struct Mi28Info{T, INT} size_r::Int64 stat::INT alpha::T + + Mi28Info{T, INT}() where {T,INT} = new{T, INT}() + + function Mi28Info{T, INT}(band_after, band_before, dup, flag, flag61, flag64, flag68, flag77, + nrestart, nshift, oor, profile_before, profile_after, size_r, stat, + alpha) where {T,INT} + return new{T, INT}(band_after, band_before, dup, flag, flag61, flag64, flag68, flag77, nrestart, + nshift, oor, profile_before, profile_after, size_r, stat, alpha) + end end function mi28_default_control(::Type{Float32}, ::Type{Int32}, control)