diff --git a/gen/rewriter.jl b/gen/rewriter.jl index 3b89303..d5e823c 100644 --- a/gen/rewriter.jl +++ b/gen/rewriter.jl @@ -79,8 +79,6 @@ function libhsl_rewrite!(path::String, name::String, optimized::Bool) if contains(code, "mutable struct") structure = code * "end\n" structure_name = split(split(code, "mutable struct ")[2], "\n")[1] - structure = replace(structure, "end\n" => "\n " * structure_name * "() where T = new()\nend\n") - arguments = "" lines = split(code, "\n", keepempty=false) for line in lines @@ -93,7 +91,8 @@ function libhsl_rewrite!(path::String, name::String, optimized::Bool) end end end - structure = replace(structure, "end\n" => "\n " * structure_name * "($arguments) where T = new($arguments)\nend\n") + structure = replace(structure, "end\n" => "\n " * structure_name * "() where T = new{T}()\nend\n") + structure = replace(structure, "end\n" => "\n " * structure_name * "($arguments) where T = new{T}($arguments)\nend\n") text = text * structure else text = text * code * "end\n" @@ -106,9 +105,12 @@ function libhsl_rewrite!(path::String, name::String, optimized::Bool) text = replace(text, "$(solver)_sinfo{$type}" => "$(solver)_sinfo") text = replace(text, Regex("$(solver)_sinfo(\\([^)]*\\)) where T") => SubstitutionString("$(solver)_sinfo\\1")) end + text = replace(text, "ma48_sinfo() = new{T}()" => "ma48_sinfo() = new()") + text = replace(text, "ma48_sinfo(flag, more, stat) = new{T}(flag, more, stat)" => "ma48_sinfo(flag, more, stat) = new(flag, more, stat)") end if name == "hsl_mc64" + text = replace(text, "new{T}" => "new") for type in ("T", "Float32", "Float64") text = replace(text, "$(solver)_control{$type}" => "$(solver)_control") text = replace(text, Regex("$(solver)_control(\\([^)]*\\)) where T") => SubstitutionString("$(solver)_control\\1")) @@ -118,6 +120,7 @@ function libhsl_rewrite!(path::String, name::String, optimized::Bool) end if name == "hsl_mc68" || name == "hsl_mc78" || name == "hsl_mc79" + text = replace(text, "new{T}" => "new") for type in ("T", "Cint", "Clong") text = replace(text, "$(solver)_control{$type}" => "$(solver)_control") text = replace(text, Regex("$(solver)_control(\\([^)]*\\)) where T") => SubstitutionString("$(solver)_control\\1")) diff --git a/src/C/libhsl/hsl_ma48.jl b/src/C/libhsl/hsl_ma48.jl index 370d7d0..7b961f5 100644 --- a/src/C/libhsl/hsl_ma48.jl +++ b/src/C/libhsl/hsl_ma48.jl @@ -24,14 +24,14 @@ mutable struct ma48_control{T} fill_in::Cint switch_mode::Cint - ma48_control{T}() where {T} = new() + ma48_control{T}() where {T} = new{T}() function ma48_control{T}(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} - return new(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) + return new{T}(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 @@ -58,13 +58,13 @@ mutable struct ma48_ainfo{T} sblock::Cint tblock::Clong - ma48_ainfo{T}() where {T} = new() + ma48_ainfo{T}() where {T} = new{T}() function ma48_ainfo{T}(ops, flag, more, lena_analyse, lenj_analyse, lena_factorize, leni_factorize, ncmpa, rank, drop, struc_rank, oor, dup, stat, lblock, sblock, tblock) where {T} - return new(ops, flag, more, lena_analyse, lenj_analyse, lena_factorize, leni_factorize, ncmpa, - rank, drop, struc_rank, oor, dup, stat, lblock, sblock, tblock) + return new{T}(ops, flag, more, lena_analyse, lenj_analyse, lena_factorize, leni_factorize, + ncmpa, rank, drop, struc_rank, oor, dup, stat, lblock, sblock, tblock) end end @@ -79,11 +79,11 @@ mutable struct ma48_finfo{T} rank::Cint stat::Cint - ma48_finfo{T}() where {T} = new() + ma48_finfo{T}() where {T} = new{T}() function ma48_finfo{T}(ops, flag, more, size_factor, lena_factorize, leni_factorize, drop, rank, stat) where {T} - return new(ops, flag, more, size_factor, lena_factorize, leni_factorize, drop, rank, stat) + return new{T}(ops, flag, more, size_factor, lena_factorize, leni_factorize, drop, rank, stat) end end diff --git a/src/C/libhsl/hsl_ma57.jl b/src/C/libhsl/hsl_ma57.jl index 06f231d..14f3769 100644 --- a/src/C/libhsl/hsl_ma57.jl +++ b/src/C/libhsl/hsl_ma57.jl @@ -28,16 +28,16 @@ mutable struct ma57_control{T} ispare::NTuple{5, Cint} rspare::NTuple{10, T} - ma57_control{T}() where {T} = new() + ma57_control{T}() where {T} = new{T}() function ma57_control{T}(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} - return new(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) + return new{T}(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 @@ -70,12 +70,12 @@ mutable struct ma57_ainfo{T} ispare::NTuple{5, Cint} rspare::NTuple{10, T} - ma57_ainfo{T}() where {T} = new() + ma57_ainfo{T}() where {T} = new{T}() function ma57_ainfo{T}(opsa, opse, flag, more, nsteps, nrltot, nirtot, nrlnec, nirnec, nrladu, niradu, ncmpa, ordering, oor, dup, maxfrt, stat, ispare, rspare) where {T} - return new(opsa, opse, flag, more, nsteps, nrltot, nirtot, nrlnec, nirnec, nrladu, niradu, - ncmpa, ordering, oor, dup, maxfrt, stat, ispare, rspare) + return new{T}(opsa, opse, flag, more, nsteps, nrltot, nirtot, nrlnec, nirnec, nrladu, niradu, + ncmpa, ordering, oor, dup, maxfrt, stat, ispare, rspare) end end @@ -115,14 +115,14 @@ mutable struct ma57_finfo{T} ispare::NTuple{5, Cint} rspare::NTuple{10, T} - ma57_finfo{T}() where {T} = new() + ma57_finfo{T}() where {T} = new{T}() function ma57_finfo{T}(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} - return new(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) + return new{T}(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 @@ -144,10 +144,10 @@ mutable struct ma57_sinfo{T} ispare::NTuple{5, Cint} rspare::NTuple{10, T} - ma57_sinfo{T}() where {T} = new() + ma57_sinfo{T}() where {T} = new{T}() function ma57_sinfo{T}(cond, cond2, berr, berr2, error, flag, stat, ispare, rspare) where {T} - return new(cond, cond2, berr, berr2, error, flag, stat, ispare, rspare) + return new{T}(cond, cond2, berr, berr2, error, flag, stat, ispare, rspare) end end diff --git a/src/C/libhsl/hsl_ma77.jl b/src/C/libhsl/hsl_ma77.jl index 2e0fd98..28fdea7 100644 --- a/src/C/libhsl/hsl_ma77.jl +++ b/src/C/libhsl/hsl_ma77.jl @@ -29,16 +29,16 @@ mutable struct ma77_control{T} lspare::NTuple{5, Clong} rspare::NTuple{5, T} - ma77_control{T}() where {T} = new() + ma77_control{T}() where {T} = new{T}() function ma77_control{T}(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} - return new(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) + return new{T}(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 @@ -82,17 +82,18 @@ mutable struct ma77_info{T} lspare::NTuple{5, Clong} rspare::NTuple{5, T} - ma77_info{T}() where {T} = new() + ma77_info{T}() where {T} = new{T}() function ma77_info{T}(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} - return new(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) + return new{T}(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 diff --git a/src/C/libhsl/hsl_ma86.jl b/src/C/libhsl/hsl_ma86.jl index da09a85..674a239 100644 --- a/src/C/libhsl/hsl_ma86.jl +++ b/src/C/libhsl/hsl_ma86.jl @@ -15,13 +15,13 @@ mutable struct ma86_control{T} umin::T scaling::Cint - ma86_control{T}() where {T} = new() + ma86_control{T}() where {T} = new{T}() function ma86_control{T}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, nemin, nb, action, nbi, pool_size, small_, static_, u, umin, scaling) where {T} - return new(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, nemin, nb, - action, nbi, pool_size, small_, static_, u, umin, scaling) + return new{T}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, nemin, + nb, action, nbi, pool_size, small_, static_, u, umin, scaling) end end @@ -47,13 +47,13 @@ mutable struct ma86_info{T} stat::Cint usmall::T - ma86_info{T}() where {T} = new() + ma86_info{T}() where {T} = new{T}() function ma86_info{T}(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} - return new(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) + return new{T}(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 diff --git a/src/C/libhsl/hsl_ma87.jl b/src/C/libhsl/hsl_ma87.jl index b1a5de2..bae8efd 100644 --- a/src/C/libhsl/hsl_ma87.jl +++ b/src/C/libhsl/hsl_ma87.jl @@ -11,12 +11,12 @@ mutable struct ma87_control{T} diag_zero_plus::T unused::NTuple{40, Cchar} - ma87_control{T}() where {T} = new() + ma87_control{T}() where {T} = new{T}() function ma87_control{T}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, nemin, nb, pool_size, diag_zero_minus, diag_zero_plus, unused) where {T} - return new(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, nemin, nb, - pool_size, diag_zero_minus, diag_zero_plus, unused) + return new{T}(f_arrays, diagnostics_level, unit_diagnostics, unit_error, unit_warning, nemin, + nb, pool_size, diag_zero_minus, diag_zero_plus, unused) end end @@ -36,12 +36,12 @@ mutable struct ma87_info{T} num_zero::Cint unused::NTuple{40, Cchar} - ma87_info{T}() where {T} = new() + ma87_info{T}() where {T} = new{T}() function ma87_info{T}(detlog, flag, maxdepth, num_factor, num_flops, num_nodes, pool_size, stat, num_zero, unused) where {T} - return new(detlog, flag, maxdepth, num_factor, num_flops, num_nodes, pool_size, stat, num_zero, - unused) + return new{T}(detlog, flag, maxdepth, num_factor, num_flops, num_nodes, pool_size, stat, + num_zero, unused) end end diff --git a/src/C/libhsl/hsl_ma97.jl b/src/C/libhsl/hsl_ma97.jl index 9115f11..47f3bf2 100644 --- a/src/C/libhsl/hsl_ma97.jl +++ b/src/C/libhsl/hsl_ma97.jl @@ -19,14 +19,14 @@ mutable struct ma97_control{T} ispare::NTuple{5, Cint} rspare::NTuple{10, T} - ma97_control{T}() where {T} = new() + ma97_control{T}() where {T} = new{T}() function ma97_control{T}(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} - return new(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) + return new{T}(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 @@ -56,15 +56,15 @@ mutable struct ma97_info{T} ispare::NTuple{4, Cint} rspare::NTuple{10, T} - ma97_info{T}() where {T} = new() + ma97_info{T}() where {T} = new{T}() function ma97_info{T}(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} - return new(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) + return new{T}(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 diff --git a/src/C/libhsl/hsl_mi20.jl b/src/C/libhsl/hsl_mi20.jl index 2b4f533..42e3e61 100644 --- a/src/C/libhsl/hsl_mi20.jl +++ b/src/C/libhsl/hsl_mi20.jl @@ -23,17 +23,17 @@ mutable struct mi20_control{T} error::Cint one_pass_coarsen::Cint - mi20_control{T}() where {T} = new() + mi20_control{T}() where {T} = new{T}() function mi20_control{T}(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} - return new(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) + return new{T}(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 @@ -51,12 +51,12 @@ mutable struct mi20_solve_control{T} preconditioner_side::Cint rel_tol::T - mi20_solve_control{T}() where {T} = new() + mi20_solve_control{T}() where {T} = new{T}() function mi20_solve_control{T}(abs_tol, breakdown_tol, gmres_restart, init_guess, krylov_solver, max_its, preconditioner_side, rel_tol) where {T} - return new(abs_tol, breakdown_tol, gmres_restart, init_guess, krylov_solver, max_its, - preconditioner_side, rel_tol) + return new{T}(abs_tol, breakdown_tol, gmres_restart, init_guess, krylov_solver, max_its, + preconditioner_side, rel_tol) end end @@ -74,11 +74,11 @@ mutable struct mi20_info{T} iterations::Cint residual::T - mi20_info{T}() where {T} = new() + mi20_info{T}() where {T} = new{T}() function mi20_info{T}(flag, clevels, cpoints, cnnz, stat, getrf_info, iterations, residual) where {T} - return new(flag, clevels, cpoints, cnnz, stat, getrf_info, iterations, residual) + return new{T}(flag, clevels, cpoints, cnnz, stat, getrf_info, iterations, residual) end end diff --git a/src/C/libhsl/hsl_mi28.jl b/src/C/libhsl/hsl_mi28.jl index 5966c83..47e88c6 100644 --- a/src/C/libhsl/hsl_mi28.jl +++ b/src/C/libhsl/hsl_mi28.jl @@ -15,13 +15,13 @@ mutable struct mi28_control{T} unit_error::Cint unit_warning::Cint - mi28_control{T}() where {T} = new() + mi28_control{T}() where {T} = new{T}() function mi28_control{T}(f_arrays, alpha, check, iorder, iscale, lowalpha, maxshift, rrt, shift_factor, shift_factor2, small, tau1, tau2, unit_error, unit_warning) where {T} - return new(f_arrays, alpha, check, iorder, iscale, lowalpha, maxshift, rrt, shift_factor, - shift_factor2, small, tau1, tau2, unit_error, unit_warning) + return new{T}(f_arrays, alpha, check, iorder, iscale, lowalpha, maxshift, rrt, shift_factor, + shift_factor2, small, tau1, tau2, unit_error, unit_warning) end end @@ -47,13 +47,13 @@ mutable struct mi28_info{T} stat::Cint alpha::T - mi28_info{T}() where {T} = new() + mi28_info{T}() where {T} = new{T}() function mi28_info{T}(band_after, band_before, dup, flag, flag61, flag64, flag68, flag77, nrestart, nshift, oor, profile_before, profile_after, size_r, stat, alpha) where {T} - return new(band_after, band_before, dup, flag, flag61, flag64, flag68, flag77, nrestart, nshift, - oor, profile_before, profile_after, size_r, stat, alpha) + return new{T}(band_after, band_before, dup, flag, flag61, flag64, flag68, flag77, nrestart, + nshift, oor, profile_before, profile_after, size_r, stat, alpha) end end