c ++ – Matrix multiplication on an upper / lower triangular matrix

I am a statistician working on DNA datasets. I write an R packet, and I will have to systematically perform the matrix multiplication on the upper-triangular (rare) matrices that have hundreds of millions columns / lines.

I'm going to multiply these matrices by low-pass and high-pass filters. For example:

enter the description of the image here

Note that when multiplying the right and center, only the first two rows of the matrix a & should be multiplied by the first column of the lower sampler, because the others all have zeros in the first two entries.

Similarly, when premultiplicating the lower sampler with the matrix "A", simply multiply the first line by the first column, because the following lines will only be multiplied by zeros.

Clearly when it is about massive these unnecessary operations will add time to the calculation that might otherwise be avoided.

My question is: is there & # 39; Multiplication Forward & # 39; function for upper triangular matrices either in the R packets Matrix or c ++ (which I can implement in CAPS) which will avoid unnecessary line / column operations that are not needed?