Changeset 15932


Ignore:
Timestamp:
05/09/18 12:18:22 (16 months ago)
Author:
bburlacu
Message:

#2919: Decide to enforce symmetry by returning values mirrored across the main diagonal.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Data/3.3/TriangularMatrix.cs

    r15931 r15932  
    7575    public override T this[int rowIndex, int columnIndex] {
    7676      get {
    77         if (columnIndex > rowIndex) return default(T); // upper triangular half is zero (default value of T)
     77        // provide symmetry of returned values
     78        if (columnIndex > rowIndex) return this[columnIndex, rowIndex];
    7879        return storage[rowIndex * (rowIndex + 1) / 2 + columnIndex];
    7980      }
    8081      set {
    81         if (columnIndex > rowIndex) throw new NotSupportedException();
    82         storage[rowIndex * (rowIndex + 1) / 2 + columnIndex] = value;
     82        if (columnIndex > rowIndex) this[columnIndex, rowIndex] = value;
     83        else storage[rowIndex * (rowIndex + 1) / 2 + columnIndex] = value;
    8384      }
    8485    }
Note: See TracChangeset for help on using the changeset viewer.