classdef ModalDecompositionCache
   % Cache for dense modal truncation.
   
   % Copyright 2023 The MathWorks, Inc.
   properties
      % Real or complex data
      REAL
      % Block size or component order
      BlockSize
      % Average mode value in each component (for complex pairs, this is the
      % value with positive imaginary part)
      Mode
      Frequency
      Damping
      % Modal components (ltipack.ssdata)
      Component
      % Feedthrough D
      Feedthrough
      % Complex DC frequency and normalized DC gain at this frequency
      DCFrequency
      DCGain
      TL
      TR
   end

   methods

      function jsel = getSelectedCol(this,select)
         % Maps selected components (blocks) into selected columns of (A,E).
         n = sum(this.BlockSize);
         cselect = false(n,1);  % selected columns
         j = 0;
         for ct=1:numel(this.BlockSize)
            bs = this.BlockSize(ct);
            cselect(j+1:j+bs,:) = select(ct);
            j = j+bs;
         end
         jsel = find(cselect);
      end

   end

end