Exemple #1
0
        private bool IsEqual(SparseMatrixD other)
        {
            if (Rows != other.Rows || Cols != other.Cols)
            {
                return(false);
            }

            return(ArrayHelpers.ArraysEqual(_values, other._values) &&
                   ArrayHelpers.ArraysEqual(_innerIndices, other._innerIndices) &&
                   ArrayHelpers.ArraysEqual(_outerStarts, other._outerStarts));
        }
Exemple #2
0
        private int NonZeroUpperBound(SparseMatrixD other)
        {
            var outerStarts           = _outerStarts;
            var outStartsOther        = other._outerStarts;
            var elementsPerColum      = new int[Cols];
            var elementsPerColumOther = new int[other.Cols];

            for (int i = 0; i <= outerStarts.Length - 2; i++)
            {
                elementsPerColum[i] = outerStarts[i + 1] - outerStarts[i];
            }

            for (int i = 0; i <= outStartsOther.Length - 2; i++)
            {
                elementsPerColumOther[i] = outStartsOther[i + 1] - outStartsOther[i];
            }

            return(Math.Min(elementsPerColum.Max() * elementsPerColumOther.Max() * Cols, Cols * Rows));
        }