public void AssignSPAToRow(int rowIndex, SPA <T> spa) { if (spa.Length != N) { throw new Exception("Incorrect SPA langth; impossible to assign to a matrix row"); } int prevLength = IA[rowIndex + 1] - IA[rowIndex]; if (IA[rowIndex] < AN.Count) { AN.RemoveRange(IA[rowIndex], prevLength); JA.RemoveRange(IA[rowIndex], prevLength); } AN.InsertRange(IA[rowIndex], spa.Data); JA.InsertRange(IA[rowIndex], spa.Indices); int diff = prevLength - spa.RealLength; if (diff != 0) { for (int i = rowIndex + 1; i < IA.Length; i++) { IA[i] -= diff; } } }