Пример #1
0
 public IOdmpMatrix <ComponentType, LineType, ColumnType, T> this[ComponentType componentIndex]
 {
     get
     {
         IOdmpMatrix <ComponentType, LineType, ColumnType, T> matrix = null;
         if (this.components.TryGetValue(componentIndex, out matrix))
         {
             return(matrix);
         }
         else
         {
             throw new OdmpProblemException("Matrix index doesn't exist.");
         }
     }
 }
Пример #2
0
        public void Set(ComponentType componentIndex, IOdmpMatrix <ComponentType, LineType, ColumnType, T> matrix)
        {
            if (matrix == null)
            {
                throw new OdmpProblemException("A matrix must be provided.");
            }

            if (this.components.ContainsKey(componentIndex))
            {
                this.components[componentIndex] = matrix;
            }
            else
            {
                this.components.Add(componentIndex, matrix);
            }
        }
Пример #3
0
        private void SetValueInMatrixSet(ComponentType component, LineType line, ColumnType column, T value)
        {
            IOdmpMatrix <ComponentType, LineType, ColumnType, T> matrix = null;

            if (!this.matrixSet.Components.TryGetValue(component, out matrix))
            {
                var innerMatrix = new OdmpSparseDictionaryMatrix <ComponentType, LineType, ColumnType, T>(component, this.defaultValue);
                innerMatrix[line, column] = value;
                this.matrixSet.Components.Add(component, innerMatrix);
            }
            else
            {
                var innerMatrix = matrix as OdmpSparseDictionaryMatrix <ComponentType, LineType, ColumnType, T>;
                innerMatrix[line, column] = value;
            }
        }