Exemplo n.º 1
0
 public CacheEntry(Key key, QrFactorization qrFactorization)
 {
     Key                       = key;
     QrFactorization           = qrFactorization;
     MatrixCrossproduct        = ImmutableMatrix.OfMatrix(ComputeMatrixCrossproduct(key.Matrix, qrFactorization.IndependentColumnIndexes));
     MatrixCrossproductInverse = ImmutableMatrix.OfMatrix(MatrixCrossproduct.Inverse());
 }
Exemplo n.º 2
0
        public CacheEntry GetQrFactorization(Matrix <double> matrix, double tolerance)
        {
            var        key = new Key(matrix, tolerance);
            CacheEntry cacheEntry;

            lock (_dictionary)
            {
                if (_dictionary.TryGetValue(key, out cacheEntry))
                {
                    return(cacheEntry);
                }
            }
            var qrFactorization = QrFactorization.GetQrFactorization(matrix, tolerance);

            lock (_dictionary)
            {
                _dictionary[key] = cacheEntry = new CacheEntry(key, qrFactorization);
            }
            return(cacheEntry);
        }