@@ -61,26 +61,26 @@ julia> grouplist = [
6161```
6262In this case, `SAFTGammaMie` files support the second order group `CH2OH`.
6363"""
64- struct GroupParam <: GroupParameter
64+ struct GroupParam{T <: Number } <: GroupParameter
6565 components:: Array{String,1}
6666 groups:: Array{Array{String,1},1}
6767 grouptype:: Symbol
68- n_groups:: Array{Array{Int ,1},1}
69- n_intergroups:: Vector{Matrix{Int }}
68+ n_groups:: Array{Array{T ,1},1}
69+ n_intergroups:: Vector{Matrix{T }}
7070 i_groups:: Array{Array{Int,1},1}
7171 flattenedgroups:: Array{String,1}
72- n_flattenedgroups:: Array{Array{Int ,1},1}
72+ n_flattenedgroups:: Array{Array{T ,1},1}
7373 sourcecsvs:: Array{String,1}
7474end
7575
76- function GroupParam (input:: PARSED_GROUP_VECTOR_TYPE )
76+ function GroupParam (input:: Vector {Tuple{String, Vector{Pair{String,T}}}}) where {T <: Number }
7777 return GroupParam (input,:unknown ,String[])
7878end
7979
8080format_components (g:: GroupParameter ) = g
8181
8282# given components, groups, n_groups, reconstitute GroupParam
83- function recombine! (param:: GroupParameter )
83+ function recombine! (param:: GroupParam{T} ) where T
8484 components = param. components
8585 groups = param. groups
8686 n_groups = param. n_groups
@@ -102,7 +102,7 @@ function recombine!(param::GroupParameter)
102102 for i in 1 : ℂ
103103 group = groups[i]
104104 if ! isassigned (i_groups,i)
105- i_groups[i] = Int []
105+ i_groups[i] = T []
106106 end
107107 i_group = i_groups[i]
108108 resize! (i_group,length (group))
@@ -148,7 +148,7 @@ function recombine!(param::GroupParameter)
148148 return param
149149end
150150
151- function GroupParam (input:: PARSED_GROUP_VECTOR_TYPE , grouptype,sourcecsvs:: Vector{String} ,gc_intragroups= nothing )
151+ function GroupParam (input:: Vector {Tuple{String, Vector{Pair{String,T}}}}, grouptype,sourcecsvs:: Vector{String} ,gc_intragroups= nothing ) where {T <: Number }
152152 grouptype = Symbol (grouptype)
153153 components = [first (i) for i ∈ input]
154154 raw_groups = [last (i) for i ∈ input]
@@ -159,15 +159,20 @@ function GroupParam(input::PARSED_GROUP_VECTOR_TYPE,grouptype,sourcecsvs::Vector
159159 n_flattenedgroups = Vector {Vector{Int}} (undef,0 )
160160 empty_intergroup = fill (0 ,(0 ,0 )) # 0x0 Matrix{Int}
161161 n_intergroups = fill (empty_intergroup,length (components))
162- param = GroupParam (components,
163- groups,
164- grouptype,
165- n_groups,
166- n_intergroups,
167- i_groups,
168- flattenedgroups,
169- n_flattenedgroups,
170- sourcecsvs)
162+
163+ _neltype (x) = eltype (eltype (x)) # nested eltype
164+ _T = promote_type (_neltype (n_groups), _neltype (n_intergroups), _neltype (i_groups), _neltype (n_flattenedgroups))
165+ param = GroupParam {_T} (
166+ components,
167+ groups,
168+ grouptype,
169+ n_groups,
170+ n_intergroups,
171+ i_groups,
172+ flattenedgroups,
173+ n_flattenedgroups,
174+ sourcecsvs
175+ )
171176 n_intergroups
172177 # do the rest of the work here
173178 if gc_intragroups != nothing
@@ -177,6 +182,49 @@ function GroupParam(input::PARSED_GROUP_VECTOR_TYPE,grouptype,sourcecsvs::Vector
177182 return param
178183end
179184
185+ function GroupParam (components,groups,grouptype,n_groups,n_intergroups,i_groups,flattenedgroups,n_flattenedgroups,sourcecsvs)
186+ TT = eltype (eltype (n_groups))
187+ return GroupParam {TT} (components,groups,grouptype,n_groups,n_intergroups,i_groups,flattenedgroups,n_flattenedgroups,sourcecsvs)
188+ end
189+
190+ function Solvers. primalval (param:: GroupParam{T} ) where T
191+ n_groups2 = Solvers. primalval_eager .(param. n_groups)
192+ n_intergroups2 = Solvers. primalval_eager .(param. n_intergroups)
193+ n_flattenedgroups2 = Solvers. primalval_eager .(param. n_flattenedgroups)
194+ T2 = Solvers. primal_eltype (eltype (eltype (n_groups2)))
195+ param = GroupParam {T2} (
196+ param. components,
197+ param. groups,
198+ param. grouptype,
199+ n_groups2,
200+ n_intergroups2,
201+ param. i_groups,
202+ param. flattenedgroups,
203+ n_flattenedgroups2,
204+ param. sourcecsvs
205+ )
206+ end
207+
208+ Base. eltype (param:: GroupParam{T} ) where T = T
209+ Base. eltype (param:: Type{<:GroupParam{T}} ) where T = T
210+
211+ function Base. convert (:: Type{GroupParam{T1}} ,param:: GroupParam{T2} ) where {T1<: Number ,T2<: Number }
212+ n_groups2 = convert .(Vector{T1},param. n_groups)
213+ n_intergroups2 = convert .(Matrix{T1},param. n_intergroups)
214+ n_flattenedgroups2 = convert .(Vector{T1},param. n_flattenedgroups)
215+ param = GroupParam {T1} (
216+ param. components,
217+ param. groups,
218+ param. grouptype,
219+ n_groups2,
220+ n_intergroups2,
221+ param. i_groups,
222+ param. flattenedgroups,
223+ n_flattenedgroups2,
224+ param. sourcecsvs
225+ )
226+ end
227+
180228function Base. show (io:: IO , mime:: MIME"text/plain" , param:: GroupParam )
181229 print (io,string (typeof (param))," (:" ,param. grouptype," ) " )
182230 len = length (param. components)
@@ -195,14 +243,14 @@ function Base.show(io::IO, param::GroupParam)
195243 print (io," ]" )
196244end
197245
198- function build_gc_intragroups! (group:: GroupParam , gc_intragroups)
246+ function build_gc_intragroups! (group:: GroupParam{T} , gc_intragroups) where T
199247 groupnames = group. flattenedgroups
200248 n_gc = length (groupnames)
201249 n_comps = length (group. components)
202- n_intergroups = [ zeros (n_gc,n_gc) for i in 1 : n_comps]
250+
203251 n_intergroups = group. n_intergroups
204252 for i in 1 : n_comps
205- n_intergroups[i] = zeros (Int ,n_gc,n_gc)
253+ n_intergroups[i] = zeros (T ,n_gc,n_gc)
206254 end
207255
208256 for i in 1 : n_comps
0 commit comments