Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/FEM/ParamDataStructures/ParamSparseMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ struct ConsecutiveParamSparseMatrixCSC{Tv,Ti<:Integer,A<:AbstractMatrix{Tv}} <:
data::A
end

function ConsecutiveParamSparseMatrixCSC(
m::Integer,
n::Integer,
colptr::Vector{Ti},
rowval::Vector{Ti},
data::A
) where {Tv,Ti<:Integer,A<:AbstractMatrix{Tv}}
ConsecutiveParamSparseMatrixCSC(Int(m),Int(n),colptr,rowval,data)
end

param_length(A::ConsecutiveParamSparseMatrixCSC) = size(A.data,2)
get_all_data(A::ConsecutiveParamSparseMatrixCSC) = A.data

Expand Down
13 changes: 13 additions & 0 deletions test/FEM/param_data_structures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ParamDataStructuresTests

using Test
using LinearAlgebra
using SparseArrays
using Gridap
using Gridap.Arrays
using Gridap.Fields
Expand Down Expand Up @@ -115,6 +116,18 @@ end
@test iszero(A[1,2])
end

@testset "ConsecutiveParamSparseMatrixCSC accepts Integer dimensions" begin
m = Int32(2)
n = Int32(3)
colptr = Int32[1,2,3,4]
rowval = Int32[1,2,1]
data = reshape([1.0,2.0,3.0],3,1)
A = ConsecutiveParamSparseMatrixCSC(m,n,colptr,rowval,data)
@test A isa ConsecutiveParamSparseMatrixCSC{Float64,Int32}
@test innersize(A) == (2,3)
@test nnz(A) == 3
end

@testset "ConsecutiveParamArray arithmetic" begin
l = 5
n = 8
Expand Down
Loading