Contiguous sparse matrices

Multivariate time series are naturally stored in the columns of a matrix in Fortran, with the data for each field being in a separate column. You may also have a 1-D array of dates or times corresponding to the rows of the matrix. Often there are time series for which the data is missing at the beginning or end of the sample, or both. For example, for stock prices, a company may have gone public after the initial date, or be delisted before the last date. So you have a matrix of data where for each column there are two integers indicating the first and last rows of available data. For this matrix you would like to perform operations such as

(1) adding or multiplying pairs of columns (creating a column and two integers with the first and last good positions)
(2) computing the correlation matrix of the columns using the data available for each pair of columns
(3) extracting subsets for which all data is present, for example excluding columns that have missing data after a certain date

There are Fortran packages for general sparse matrices and for matrices with nonzero elements only near the diagonal. Has someone created a derived type to handle matrices with nonzero elements that are contiguous in each column? If not, I may do so.

1 Like

Not exactly an answer but would one of the two sparse formats discussed here be close to what you are looking for (CSX and SELL-C-sigma)? From my very shallow understanding of those formats they try to exploit dense patterns within the sparse matrix, thus constructing indexing for fast access of sub-blocks.