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."); } } }
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); } }
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; } }