protected TensorDimensionsBase(IImmutableList<int> immutableDimensions)
        {
            m_dims = immutableDimensions;

            // Precompute this since we are immutable.
            ElementCount = IsEmpty ? 0 : Math.Abs(m_dims.Aggregate(1, (acc, item) => acc * item));  // Tolerate -1s.
        }
Ejemplo n.º 2
0
        public override int GetHashCode()
        {
            if (m_hashCode == -1)
            {
                m_hashCode = IsEmpty ? 0 : m_dims.Aggregate(19, (acc, item) => 31 * acc + item);
            }

            return(m_hashCode);
        }
Ejemplo n.º 3
0
        public Dimensions(IImmutableList <int> immutableDimensions)
        {
            if (immutableDimensions.Count > MaxDimensions)
            {
                throw new InvalidDimensionsException($"Maximum number of dimensions is {MaxDimensions}.");
            }

            m_dims = immutableDimensions;

            // Precompute this since we are immutable.
            ElementCount = IsEmpty ? 0 : Math.Abs(m_dims.Aggregate(1, (acc, item) => acc * item));  // Tolerate -1s.
        }