I am trying to restructure some code in Mosel and use sets of records to represent the indices of sparse multi-dimensional arrays. I want to be able to populate my sets of records dynamically, so I can't use the initialisation stuff from a file or database.
I have:
declarations
myTuple = record
index1 : string
index2 : string
end-record
sparseIndex : set of myTuple
end-declarations
and then I want to do something like:
forall (a in largeListOfStrings)
forall (b in anotherListOfStrings)
if (someCondition(a,b)) then
sparseIndex += { new myTuple(a, b) }
but in Mosel there is no "new" keyword or operator, and the documentation appears quite weak on this point so I just don't know how to create a new instance of my record and initialise it so I can add it to my dynamic set.
Alternatively, I may be just thinking about this the wrong way - is there a better way to create a sparse index set that retains access to the components of the sparse index.
You do not need to define a record for this case. Mosel is great to keep information of sparse arrays. You should do something like:
So from now on your sparse matrix will be kept inside my list. Any time you want to iterate through it, you should use a logic like: