Exemple #1
0
        public void Finish(IFeatureCollection collection)
        {
            var times = collection.GetFeature <ITimeStepsFeature>().Times;

            _localMatrix = _model.LocalCorrelationObjects(times);
            //var localMatrixObjects = _localMatrix.Select(x=>new CorrelationMatrix()
            var pathFeatures = collection.GetFeature <IPathMappingFeature>();

            _localMatrixSquare = new List <double[][]>();
            var dimNames = pathFeatures.GetDimensionNames();

            for (var t = 0; t < _localMatrix.Count; t++)
            {
                _localMatrixSquare.Add(new double[pathFeatures.NumberOfDimensions][]);
                for (var i = 0; i < _localMatrixSquare[t].Length; i++)
                {
                    _localMatrixSquare[t][i] = new double[pathFeatures.NumberOfDimensions];
                    for (var j = 0; j < _localMatrixSquare[t][i].Length; j++)
                    {
                        _localMatrixSquare[t][i][j] = i == j ? 1.0 : (_localMatrix[t].TryGetCorrelation(dimNames[i], dimNames[j], out var correl) ? correl : 0.0);
                    }
                }
            }

            _decompMatrix = _localMatrixSquare.Select(l => l.Cholesky2()).ToList();
            _isComplete   = true;
        }