Exemplo n.º 1
0
 /// <summary>
 /// Return the cumulative product of elements along a given axis.
 ///
 /// Notes
 ///
 /// Arithmetic is modular when using integer types, and no error is
 /// raised on overflow.
 /// </summary>
 /// <param name="a">
 /// Input array.
 /// </param>
 /// <param name="axis">
 /// Axis along which the cumulative product is computed.  By default
 /// the input is flattened.
 /// </param>
 /// <param name="dtype">
 /// Type of the returned array, as well as of the accumulator in which
 /// the elements are multiplied.  If dtype is not specified, it
 /// defaults to the dtype of a, unless a has an integer dtype with
 /// a precision less than that of the default platform integer.  In
 /// that case, the default platform integer is used instead.
 /// </param>
 /// <param name="@out">
 /// Alternative output array in which to place the result. It must
 /// have the same shape and buffer length as the expected output
 /// but the type of the resulting values will be cast if necessary.
 /// </param>
 /// <returns>
 /// A new array holding the result is returned unless out is
 /// specified, in which case a reference to out is returned.
 /// </returns>
 public static NDarray cumprod(NDarray a, int?axis = null, Dtype dtype = null, NDarray @out = null)
 => NumPy.Instance.cumprod(a, axis: axis, dtype: dtype, @out: @out);
Exemplo n.º 2
0
 /// <summary>
 /// Return the cumulative sum of array elements over a given axis treating Not a
 /// Numbers (NaNs) as zero.  The cumulative sum does not change when NaNs are
 /// encountered and leading NaNs are replaced by zeros.
 ///
 /// Zeros are returned for slices that are all-NaN or empty.
 /// </summary>
 /// <param name="a">
 /// Input array.
 /// </param>
 /// <param name="axis">
 /// Axis along which the cumulative sum is computed. The default
 /// (None) is to compute the cumsum over the flattened array.
 /// </param>
 /// <param name="dtype">
 /// Type of the returned array and of the accumulator in which the
 /// elements are summed.  If dtype is not specified, it defaults
 /// to the dtype of a, unless a has an integer dtype with a
 /// precision less than that of the default platform integer.  In
 /// that case, the default platform integer is used.
 /// </param>
 /// <param name="@out">
 /// Alternative output array in which to place the result. It must
 /// have the same shape and buffer length as the expected output
 /// but the type will be cast if necessary. See doc.ufuncs
 /// (Section “Output arguments”) for more details.
 /// </param>
 /// <returns>
 /// A new array holding the result is returned unless out is
 /// specified, in which it is returned. The result has the same
 /// size as a, and the same shape as a if axis is not None
 /// or a is a 1-d array.
 /// </returns>
 public static NDarray nancumsum(NDarray a, int?axis = null, Dtype dtype = null, NDarray @out = null)
 => NumPy.Instance.nancumsum(a, axis: axis, dtype: dtype, @out: @out);
Exemplo n.º 3
0
 /// <summary>
 /// Sum of array elements over a given axis.
 ///
 /// Notes
 ///
 /// Arithmetic is modular when using integer types, and no error is
 /// raised on overflow.
 ///
 /// The sum of an empty array is the neutral element 0:
 /// </summary>
 /// <param name="a">
 /// Elements to sum.
 /// </param>
 /// <param name="axis">
 /// Axis or axes along which a sum is performed.  The default,
 /// axis=None, will sum all of the elements of the input array.  If
 /// axis is negative it counts from the last to the first axis.
 ///
 /// If axis is a tuple of ints, a sum is performed on all of the axes
 /// specified in the tuple instead of a single axis or all the axes as
 /// before.
 /// </param>
 /// <param name="dtype">
 /// The type of the returned array and of the accumulator in which the
 /// elements are summed.  The dtype of a is used by default unless a
 /// has an integer dtype of less precision than the default platform
 /// integer.  In that case, if a is signed then the platform integer
 /// is used while if a is unsigned then an unsigned integer of the
 /// same precision as the platform integer is used.
 /// </param>
 /// <param name="@out">
 /// Alternative output array in which to place the result. It must have
 /// the same shape as the expected output, but the type of the output
 /// values will be cast if necessary.
 /// </param>
 /// <param name="keepdims">
 /// If this is set to True, the axes which are reduced are left
 /// in the result as dimensions with size one. With this option,
 /// the result will broadcast correctly against the input array.
 ///
 /// If the default value is passed, then keepdims will not be
 /// passed through to the sum method of sub-classes of
 /// ndarray, however any non-default value will be.  If the
 /// sub-class’ method does not implement keepdims any
 /// exceptions will be raised.
 /// </param>
 /// <param name="initial">
 /// Starting value for the sum. See reduce for details.
 /// </param>
 /// <returns>
 /// An array with the same shape as a, with the specified
 /// axis removed.   If a is a 0-d array, or if axis is None, a scalar
 /// is returned.  If an output array is specified, a reference to
 /// out is returned.
 /// </returns>
 public static NDarray sum(NDarray a, int[] axis = null, Dtype dtype = null, NDarray @out = null, bool?keepdims = null, ValueType initial = null)
 => NumPy.Instance.sum(a, axis: axis, dtype: dtype, @out: @out, keepdims: keepdims, initial: initial);
Exemplo n.º 4
0
 /// <summary>
 /// Return the sum of array elements over a given axis treating Not a
 /// Numbers (NaNs) as zero.
 ///
 /// In NumPy versions &lt;= 1.9.0 Nan is returned for slices that are all-NaN or
 /// empty. In later versions zero is returned.
 ///
 /// Notes
 ///
 /// If both positive and negative infinity are present, the sum will be Not
 /// A Number (NaN).
 /// </summary>
 /// <param name="a">
 /// Array containing numbers whose sum is desired. If a is not an
 /// array, a conversion is attempted.
 /// </param>
 /// <param name="axis">
 /// Axis or axes along which the sum is computed. The default is to compute the
 /// sum of the flattened array.
 /// </param>
 /// <param name="dtype">
 /// The type of the returned array and of the accumulator in which the
 /// elements are summed.  By default, the dtype of a is used.  An
 /// exception is when a has an integer type with less precision than
 /// the platform (u)intp. In that case, the default will be either
 /// (u)int32 or (u)int64 depending on whether the platform is 32 or 64
 /// bits. For inexact inputs, dtype must be inexact.
 /// </param>
 /// <param name="@out">
 /// Alternate output array in which to place the result.  The default
 /// is None. If provided, it must have the same shape as the
 /// expected output, but the type will be cast if necessary.  See
 /// doc.ufuncs for details. The casting of NaN to integer can yield
 /// unexpected results.
 /// </param>
 /// <param name="keepdims">
 /// If this is set to True, the axes which are reduced are left
 /// in the result as dimensions with size one. With this option,
 /// the result will broadcast correctly against the original a.
 ///
 /// If the value is anything but the default, then
 /// keepdims will be passed through to the mean or sum methods
 /// of sub-classes of ndarray.  If the sub-classes methods
 /// does not implement keepdims any exceptions will be raised.
 /// </param>
 /// <returns>
 /// A new array holding the result is returned unless out is
 /// specified, in which it is returned. The result has the same
 /// size as a, and the same shape as a if axis is not None
 /// or a is a 1-d array.
 /// </returns>
 public static NDarray nansum(NDarray a, int[] axis = null, Dtype dtype = null, NDarray @out = null, bool?keepdims = null)
 => NumPy.Instance.nansum(a, axis: axis, dtype: dtype, @out: @out, keepdims: keepdims);
Exemplo n.º 5
0
        /// <summary>
        ///	Return the sum along diagonals of the array.<br></br>
        ///
        ///	If a is 2-D, the sum along its diagonal with the given offset
        ///	is returned, i.e., the sum of elements a[i,i+offset] for all i.<br></br>
        ///
        ///	If a has more than two dimensions, then the axes specified by axis1 and
        ///	axis2 are used to determine the 2-D sub-arrays whose traces are returned.<br></br>
        ///
        ///	The shape of the resulting array is the same as that of a with axis1
        ///	and axis2 removed.
        /// </summary>
        /// <param name="a">
        ///	Input array, from which the diagonals are taken.
        /// </param>
        /// <param name="offset">
        ///	Offset of the diagonal from the main diagonal.<br></br>
        ///	Can be both positive
        ///	and negative.<br></br>
        ///	Defaults to 0.
        /// </param>
        /// <param name="axis2">
        ///	Axes to be used as the first and second axis of the 2-D sub-arrays
        ///	from which the diagonals should be taken.<br></br>
        ///	Defaults are the first two
        ///	axes of a.
        /// </param>
        /// <param name="axis1">
        ///	Axes to be used as the first and second axis of the 2-D sub-arrays
        ///	from which the diagonals should be taken.<br></br>
        ///	Defaults are the first two
        ///	axes of a.
        /// </param>
        /// <param name="dtype">
        ///	Determines the data-type of the returned array and of the accumulator
        ///	where the elements are summed.<br></br>
        ///	If dtype has the value None and a is
        ///	of integer type of precision less than the default integer
        ///	precision, then the default integer precision is used.<br></br>
        ///	Otherwise,
        ///	the precision is the same as that of a.
        /// </param>
        /// <param name="out">
        ///	Array into which the output is placed.<br></br>
        ///	Its type is preserved and
        ///	it must be of the right shape to hold the output.
        /// </param>
        /// <returns>
        ///	If a is 2-D, the sum along the diagonal is returned.<br></br>
        ///	  If a has
        ///	larger dimensions, then an array of sums along diagonals is returned.
        /// </returns>
        public static NDarray trace(NDarray a, int?offset = 0, int?axis2 = null, int?axis1 = null, Dtype dtype = null, NDarray @out = null)
        {
            //auto-generated code, do not change
            var __self__ = self;
            var pyargs   = ToTuple(new object[]
            {
                a,
            });
            var kwargs = new PyDict();

            if (offset != 0)
            {
                kwargs["offset"] = ToPython(offset);
            }
            if (axis2 != null)
            {
                kwargs["axis2"] = ToPython(axis2);
            }
            if (axis1 != null)
            {
                kwargs["axis1"] = ToPython(axis1);
            }
            if (dtype != null)
            {
                kwargs["dtype"] = ToPython(dtype);
            }
            if (@out != null)
            {
                kwargs["out"] = ToPython(@out);
            }
            dynamic py = __self__.InvokeMethod("trace", pyargs, kwargs);

            return(ToCsharp <NDarray>(py));
        }
Exemplo n.º 6
0
        /// <summary>
        ///	Evaluates the Einstein summation convention on the operands.<br></br>
        ///
        ///	Using the Einstein summation convention, many common multi-dimensional,
        ///	linear algebraic array operations can be represented in a simple fashion.<br></br>
        ///
        ///	In implicit mode einsum computes these values.<br></br>
        ///
        ///	In explicit mode, einsum provides further flexibility to compute
        ///	other array operations that might not be considered classical Einstein
        ///	summation operations, by disabling, or forcing summation over specified
        ///	subscript labels.<br></br>
        ///
        ///	See the notes and examples for clarification.<br></br>
        ///
        ///	Notes
        ///
        ///	The Einstein summation convention can be used to compute
        ///	many multi-dimensional, linear algebraic array operations.<br></br>
        ///	 einsum
        ///	provides a succinct way of representing these.<br></br>
        ///
        ///	A non-exhaustive list of these operations,
        ///	which can be computed by einsum, is shown below along with examples:
        ///
        ///	The subscripts string is a comma-separated list of subscript labels,
        ///	where each label refers to a dimension of the corresponding operand.<br></br>
        ///
        ///	Whenever a label is repeated it is summed, so np.einsum('i,i', a, b)
        ///	is equivalent to np.inner(a,b).<br></br>
        ///	 If a label
        ///	appears only once, it is not summed, so np.einsum('i', a) produces a
        ///	view of a with no changes.<br></br>
        ///	 A further example np.einsum('ij,jk', a, b)
        ///	describes traditional matrix multiplication and is equivalent to
        ///	np.matmul(a,b).<br></br>
        ///	 Repeated subscript labels in one
        ///	operand take the diagonal.<br></br>
        ///	 For example, np.einsum('ii', a) is equivalent
        ///	to np.trace(a).<br></br>
        ///
        ///	In implicit mode, the chosen subscripts are important
        ///	since the axes of the output are reordered alphabetically.<br></br>
        ///	  This
        ///	means that np.einsum('ij', a) doesn’t affect a 2D array, while
        ///	np.einsum('ji', a) takes its transpose.<br></br>
        ///	 Additionally,
        ///	np.einsum('ij,jk', a, b) returns a matrix multiplication, while,
        ///	np.einsum('ij,jh', a, b) returns the transpose of the
        ///	multiplication since subscript ‘h’ precedes subscript ‘i’.
        ///
        ///	In explicit mode the output can be directly controlled by
        ///	specifying output subscript labels.<br></br>
        ///	  This requires the
        ///	identifier ‘-&gt;’ as well as the list of output subscript labels.<br></br>
        ///
        ///	This feature increases the flexibility of the function since
        ///	summing can be disabled or forced when required.<br></br>
        ///	 The call
        ///	np.einsum('i-&gt;', a) is like np.sum(a, axis=-1),
        ///	and np.einsum('ii-&gt;i', a) is like np.diag(a).<br></br>
        ///
        ///	The difference is that einsum does not allow broadcasting by default.<br></br>
        ///
        ///	Additionally np.einsum('ij,jh-&gt;ih', a, b) directly specifies the
        ///	order of the output subscript labels and therefore returns matrix
        ///	multiplication, unlike the example above in implicit mode.<br></br>
        ///
        ///	To enable and control broadcasting, use an ellipsis.<br></br>
        ///	  Default
        ///	NumPy-style broadcasting is done by adding an ellipsis
        ///	to the left of each term, like np.einsum('...ii-&gt;...i', a).<br></br>
        ///
        ///	To take the trace along the first and last axes,
        ///	you can do np.einsum('i...i', a), or to do a matrix-matrix
        ///	product with the left-most indices instead of rightmost, one can do
        ///	np.einsum('ij...,jk...-&gt;ik...', a, b).<br></br>
        ///
        ///	When there is only one operand, no axes are summed, and no output
        ///	parameter is provided, a view into the operand is returned instead
        ///	of a new array.<br></br>
        ///	  Thus, taking the diagonal as np.einsum('ii-&gt;i', a)
        ///	produces a view (changed in version 1.10.0).<br></br>
        ///
        ///	einsum also provides an alternative way to provide the subscripts
        ///	and operands as einsum(op0, sublist0, op1, sublist1, ..., [sublistout]).<br></br>
        ///
        ///	If the output shape is not provided in this format einsum will be
        ///	calculated in implicit mode, otherwise it will be performed explicitly.<br></br>
        ///
        ///	The examples below have corresponding einsum calls with the two
        ///	parameter methods.<br></br>
        ///
        ///	Views returned from einsum are now writeable whenever the input array
        ///	is writeable.<br></br>
        ///	 For example, np.einsum('ijk...-&gt;kji...', a) will now
        ///	have the same effect as np.swapaxes(a, 0, 2)
        ///	and np.einsum('ii-&gt;i', a) will return a writeable view of the diagonal
        ///	of a 2D array.<br></br>
        ///
        ///	Added the optimize argument which will optimize the contraction order
        ///	of an einsum expression.<br></br>
        ///	 For a contraction with three or more operands this
        ///	can greatly increase the computational efficiency at the cost of a larger
        ///	memory footprint during computation.<br></br>
        ///
        ///	Typically a ‘greedy’ algorithm is applied which empirical tests have shown
        ///	returns the optimal path in the majority of cases.<br></br>
        ///	 In some cases ‘optimal’
        ///	will return the superlative path through a more expensive, exhaustive search.<br></br>
        ///
        ///	For iterative calculations it may be advisable to calculate the optimal path
        ///	once and reuse that path by supplying it as an argument.<br></br>
        ///	 An example is given
        ///	below.<br></br>
        ///
        ///	See numpy.einsum_path for more details.
        /// </summary>
        /// <param name="subscripts">
        ///	Specifies the subscripts for summation as comma separated list of
        ///	subscript labels.<br></br>
        ///	An implicit (classical Einstein summation)
        ///	calculation is performed unless the explicit indicator ‘-&gt;’ is
        ///	included as well as subscript labels of the precise output form.
        /// </param>
        /// <param name="operands">
        ///	These are the arrays for the operation.
        /// </param>
        /// <param name="out">
        ///	If provided, the calculation is done into this array.
        /// </param>
        /// <param name="dtype">
        ///	If provided, forces the calculation to use the data type specified.<br></br>
        ///
        ///	Note that you may have to also give a more liberal casting
        ///	parameter to allow the conversions.<br></br>
        ///	Default is None.
        /// </param>
        /// <param name="order">
        ///	Controls the memory layout of the output.<br></br>
        ///	‘C’ means it should
        ///	be C contiguous.<br></br>
        ///	‘F’ means it should be Fortran contiguous,
        ///	‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise.<br></br>
        ///
        ///	‘K’ means it should be as close to the layout as the inputs as
        ///	is possible, including arbitrarily permuted axes.<br></br>
        ///
        ///	Default is ‘K’.
        /// </param>
        /// <param name="casting">
        ///	Controls what kind of data casting may occur.<br></br>
        ///	Setting this to
        ///	‘unsafe’ is not recommended, as it can adversely affect accumulations.<br></br>
        ///
        ///	Default is ‘safe’.
        /// </param>
        /// <param name="optimize">
        ///	Controls if intermediate optimization should occur.<br></br>
        ///	No optimization
        ///	will occur if False and True will default to the ‘greedy’ algorithm.<br></br>
        ///
        ///	Also accepts an explicit contraction list from the np.einsum_path
        ///	function.<br></br>
        ///	See np.einsum_path for more details.<br></br>
        ///	Defaults to False.
        /// </param>
        /// <returns>
        ///	The calculation based on the Einstein summation convention.
        /// </returns>
        public static NDarray einsum(string subscripts, NDarray[] operands, NDarray @out = null, Dtype dtype = null, string order = null, string casting = "safe", object optimize = null)
        {
            //auto-generated code, do not change
            var __self__ = self;
            var pyargs   = ToTuple(new object[]
            {
                subscripts,
                operands,
            });
            var kwargs = new PyDict();

            if (@out != null)
            {
                kwargs["out"] = ToPython(@out);
            }
            if (dtype != null)
            {
                kwargs["dtype"] = ToPython(dtype);
            }
            if (order != null)
            {
                kwargs["order"] = ToPython(order);
            }
            if (casting != "safe")
            {
                kwargs["casting"] = ToPython(casting);
            }
            if (optimize != null)
            {
                kwargs["optimize"] = ToPython(optimize);
            }
            dynamic py = __self__.InvokeMethod("einsum", pyargs, kwargs);

            return(ToCsharp <NDarray>(py));
        }
Exemplo n.º 7
0
 /// <summary>
 ///	Evaluates the Einstein summation convention on the operands.<br></br>
 ///
 ///	Using the Einstein summation convention, many common multi-dimensional,
 ///	linear algebraic array operations can be represented in a simple fashion.<br></br>
 ///
 ///	In implicit mode einsum computes these values.<br></br>
 ///
 ///	In explicit mode, einsum provides further flexibility to compute
 ///	other array operations that might not be considered classical Einstein
 ///	summation operations, by disabling, or forcing summation over specified
 ///	subscript labels.<br></br>
 ///
 ///	See the notes and examples for clarification.<br></br>
 ///
 ///	Notes
 ///
 ///	The Einstein summation convention can be used to compute
 ///	many multi-dimensional, linear algebraic array operations.<br></br>
 ///	 einsum
 ///	provides a succinct way of representing these.<br></br>
 ///
 ///	A non-exhaustive list of these operations,
 ///	which can be computed by einsum, is shown below along with examples:
 ///
 ///	The subscripts string is a comma-separated list of subscript labels,
 ///	where each label refers to a dimension of the corresponding operand.<br></br>
 ///
 ///	Whenever a label is repeated it is summed, so np.einsum('i,i', a, b)
 ///	is equivalent to np.inner(a,b).<br></br>
 ///	 If a label
 ///	appears only once, it is not summed, so np.einsum('i', a) produces a
 ///	view of a with no changes.<br></br>
 ///	 A further example np.einsum('ij,jk', a, b)
 ///	describes traditional matrix multiplication and is equivalent to
 ///	np.matmul(a,b).<br></br>
 ///	 Repeated subscript labels in one
 ///	operand take the diagonal.<br></br>
 ///	 For example, np.einsum('ii', a) is equivalent
 ///	to np.trace(a).<br></br>
 ///
 ///	In implicit mode, the chosen subscripts are important
 ///	since the axes of the output are reordered alphabetically.<br></br>
 ///	  This
 ///	means that np.einsum('ij', a) doesn’t affect a 2D array, while
 ///	np.einsum('ji', a) takes its transpose.<br></br>
 ///	 Additionally,
 ///	np.einsum('ij,jk', a, b) returns a matrix multiplication, while,
 ///	np.einsum('ij,jh', a, b) returns the transpose of the
 ///	multiplication since subscript ‘h’ precedes subscript ‘i’.
 ///
 ///	In explicit mode the output can be directly controlled by
 ///	specifying output subscript labels.<br></br>
 ///	  This requires the
 ///	identifier ‘-&gt;’ as well as the list of output subscript labels.<br></br>
 ///
 ///	This feature increases the flexibility of the function since
 ///	summing can be disabled or forced when required.<br></br>
 ///	 The call
 ///	np.einsum('i-&gt;', a) is like np.sum(a, axis=-1),
 ///	and np.einsum('ii-&gt;i', a) is like np.diag(a).<br></br>
 ///
 ///	The difference is that einsum does not allow broadcasting by default.<br></br>
 ///
 ///	Additionally np.einsum('ij,jh-&gt;ih', a, b) directly specifies the
 ///	order of the output subscript labels and therefore returns matrix
 ///	multiplication, unlike the example above in implicit mode.<br></br>
 ///
 ///	To enable and control broadcasting, use an ellipsis.<br></br>
 ///	  Default
 ///	NumPy-style broadcasting is done by adding an ellipsis
 ///	to the left of each term, like np.einsum('...ii-&gt;...i', a).<br></br>
 ///
 ///	To take the trace along the first and last axes,
 ///	you can do np.einsum('i...i', a), or to do a matrix-matrix
 ///	product with the left-most indices instead of rightmost, one can do
 ///	np.einsum('ij...,jk...-&gt;ik...', a, b).<br></br>
 ///
 ///	When there is only one operand, no axes are summed, and no output
 ///	parameter is provided, a view into the operand is returned instead
 ///	of a new array.<br></br>
 ///	  Thus, taking the diagonal as np.einsum('ii-&gt;i', a)
 ///	produces a view (changed in version 1.10.0).<br></br>
 ///
 ///	einsum also provides an alternative way to provide the subscripts
 ///	and operands as einsum(op0, sublist0, op1, sublist1, ..., [sublistout]).<br></br>
 ///
 ///	If the output shape is not provided in this format einsum will be
 ///	calculated in implicit mode, otherwise it will be performed explicitly.<br></br>
 ///
 ///	The examples below have corresponding einsum calls with the two
 ///	parameter methods.<br></br>
 ///
 ///	Views returned from einsum are now writeable whenever the input array
 ///	is writeable.<br></br>
 ///	 For example, np.einsum('ijk...-&gt;kji...', a) will now
 ///	have the same effect as np.swapaxes(a, 0, 2)
 ///	and np.einsum('ii-&gt;i', a) will return a writeable view of the diagonal
 ///	of a 2D array.<br></br>
 ///
 ///	Added the optimize argument which will optimize the contraction order
 ///	of an einsum expression.<br></br>
 ///	 For a contraction with three or more operands this
 ///	can greatly increase the computational efficiency at the cost of a larger
 ///	memory footprint during computation.<br></br>
 ///
 ///	Typically a ‘greedy’ algorithm is applied which empirical tests have shown
 ///	returns the optimal path in the majority of cases.<br></br>
 ///	 In some cases ‘optimal’
 ///	will return the superlative path through a more expensive, exhaustive search.<br></br>
 ///
 ///	For iterative calculations it may be advisable to calculate the optimal path
 ///	once and reuse that path by supplying it as an argument.<br></br>
 ///	 An example is given
 ///	below.<br></br>
 ///
 ///	See numpy.einsum_path for more details.
 /// </summary>
 /// <param name="subscripts">
 ///	Specifies the subscripts for summation as comma separated list of
 ///	subscript labels.<br></br>
 ///	An implicit (classical Einstein summation)
 ///	calculation is performed unless the explicit indicator ‘-&gt;’ is
 ///	included as well as subscript labels of the precise output form.
 /// </param>
 /// <param name="operands">
 ///	These are the arrays for the operation.
 /// </param>
 /// <param name="out">
 ///	If provided, the calculation is done into this array.
 /// </param>
 /// <param name="dtype">
 ///	If provided, forces the calculation to use the data type specified.<br></br>
 ///
 ///	Note that you may have to also give a more liberal casting
 ///	parameter to allow the conversions.<br></br>
 ///	Default is None.
 /// </param>
 /// <param name="order">
 ///	Controls the memory layout of the output.<br></br>
 ///	‘C’ means it should
 ///	be C contiguous.<br></br>
 ///	‘F’ means it should be Fortran contiguous,
 ///	‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise.<br></br>
 ///
 ///	‘K’ means it should be as close to the layout as the inputs as
 ///	is possible, including arbitrarily permuted axes.<br></br>
 ///
 ///	Default is ‘K’.
 /// </param>
 /// <param name="casting">
 ///	Controls what kind of data casting may occur.<br></br>
 ///	Setting this to
 ///	‘unsafe’ is not recommended, as it can adversely affect accumulations.<br></br>
 ///
 ///	Default is ‘safe’.
 /// </param>
 /// <param name="optimize">
 ///	Controls if intermediate optimization should occur.<br></br>
 ///	No optimization
 ///	will occur if False and True will default to the ‘greedy’ algorithm.<br></br>
 ///
 ///	Also accepts an explicit contraction list from the np.einsum_path
 ///	function.<br></br>
 ///	See np.einsum_path for more details.<br></br>
 ///	Defaults to False.
 /// </param>
 /// <returns>
 ///	The calculation based on the Einstein summation convention.
 /// </returns>
 public static NDarray einsum(string subscripts, NDarray[] operands, NDarray @out = null, Dtype dtype = null, string order = null, string casting = "safe", object optimize = null)
 => NumPy.Instance.einsum(subscripts, operands, @out: @out, dtype: dtype, order: order, casting: casting, optimize: optimize);
Exemplo n.º 8
0
 /// <summary>
 ///	Return the sum along diagonals of the array.<br></br>
 ///
 ///	If a is 2-D, the sum along its diagonal with the given offset
 ///	is returned, i.e., the sum of elements a[i,i+offset] for all i.<br></br>
 ///
 ///	If a has more than two dimensions, then the axes specified by axis1 and
 ///	axis2 are used to determine the 2-D sub-arrays whose traces are returned.<br></br>
 ///
 ///	The shape of the resulting array is the same as that of a with axis1
 ///	and axis2 removed.
 /// </summary>
 /// <param name="a">
 ///	Input array, from which the diagonals are taken.
 /// </param>
 /// <param name="offset">
 ///	Offset of the diagonal from the main diagonal.<br></br>
 ///	Can be both positive
 ///	and negative.<br></br>
 ///	Defaults to 0.
 /// </param>
 /// <param name="axis2">
 ///	Axes to be used as the first and second axis of the 2-D sub-arrays
 ///	from which the diagonals should be taken.<br></br>
 ///	Defaults are the first two
 ///	axes of a.
 /// </param>
 /// <param name="axis1">
 ///	Axes to be used as the first and second axis of the 2-D sub-arrays
 ///	from which the diagonals should be taken.<br></br>
 ///	Defaults are the first two
 ///	axes of a.
 /// </param>
 /// <param name="dtype">
 ///	Determines the data-type of the returned array and of the accumulator
 ///	where the elements are summed.<br></br>
 ///	If dtype has the value None and a is
 ///	of integer type of precision less than the default integer
 ///	precision, then the default integer precision is used.<br></br>
 ///	Otherwise,
 ///	the precision is the same as that of a.
 /// </param>
 /// <param name="out">
 ///	Array into which the output is placed.<br></br>
 ///	Its type is preserved and
 ///	it must be of the right shape to hold the output.
 /// </param>
 /// <returns>
 ///	If a is 2-D, the sum along the diagonal is returned.<br></br>
 ///	  If a has
 ///	larger dimensions, then an array of sums along diagonals is returned.
 /// </returns>
 public static NDarray trace(NDarray a, int?offset = 0, int?axis2 = null, int?axis1 = null, Dtype dtype = null, NDarray @out = null)
 => NumPy.Instance.trace(a, offset: offset, axis2: axis2, axis1: axis1, dtype: dtype, @out: @out);
 /// <summary>
 ///	Get information about the step size of a date or time type.<br></br>
 ///
 ///	The returned tuple can be passed as the second argument of numpy.datetime64 and
 ///	numpy.timedelta64.
 /// </summary>
 /// <param name="dtype">
 ///	The dtype object, which must be a datetime64 or timedelta64 type.
 /// </param>
 /// <returns>
 /// A tuple of:
 /// unit
 ///	The datetime unit on which this dtype
 ///	is based.
 /// count
 ///	The number of base units in a step.
 /// </returns>
 public static (string, int) datetime_data(Dtype dtype)
 => NumPy.Instance.datetime_data(dtype);
Exemplo n.º 10
0
        /*
         * /// <summary>
         * /// Format a floating-point scalar as a decimal string in positional notation.
         * ///
         * /// Provides control over rounding, trimming and padding. Uses and assumes
         * /// IEEE unbiased rounding. Uses the “Dragon4” algorithm.
         * /// </summary>
         * /// <param name="x">
         * /// Value to format.
         * /// </param>
         * /// <param name="precision">
         * /// Maximum number of digits to print. May be None if unique is
         * /// True, but must be an integer if unique is False.
         * /// </param>
         * /// <param name="unique">
         * /// If True, use a digit-generation strategy which gives the shortest
         * /// representation which uniquely identifies the floating-point number from
         * /// other values of the same type, by judicious rounding. If precision
         * /// was omitted, print out all necessary digits, otherwise digit generation
         * /// is cut off after precision digits and the remaining value is rounded.
         * /// If False, digits are generated as if printing an infinite-precision
         * /// value and stopping after precision digits, rounding the remaining
         * /// value.
         * /// </param>
         * /// <param name="fractional">
         * /// If True, the cutoff of precision digits refers to the total number
         * /// of digits after the decimal point, including leading zeros.
         * /// If False, precision refers to the total number of significant
         * /// digits, before or after the decimal point, ignoring leading zeros.
         * /// </param>
         * /// <param name="trim">
         * /// Controls post-processing trimming of trailing digits, as follows:
         * /// </param>
         * /// <param name="sign">
         * /// Whether to show the sign for positive values.
         * /// </param>
         * /// <param name="pad_left">
         * /// Pad the left side of the string with whitespace until at least that
         * /// many characters are to the left of the decimal point.
         * /// </param>
         * /// <param name="pad_right">
         * /// Pad the right side of the string with whitespace until at least that
         * /// many characters are to the right of the decimal point.
         * /// </param>
         * /// <returns>
         * /// The string representation of the floating point value
         * /// </returns>
         * public static string format_float_positional(python float or numpy floating scalar x, non-negative integer or None precision = null, bool? unique = true, bool? fractional = true, one of ‘k’ trim = "k", bool? sign = false, non-negative integer pad_left = null, non-negative integer pad_right = null)
         *  => NumPy.Instance.format_float_positional(x, precision:precision, unique:unique, fractional:fractional, trim:trim, sign:sign, pad_left:pad_left, pad_right:pad_right);
         */

        /*
         * /// <summary>
         * /// Format a floating-point scalar as a decimal string in scientific notation.
         * ///
         * /// Provides control over rounding, trimming and padding. Uses and assumes
         * /// IEEE unbiased rounding. Uses the “Dragon4” algorithm.
         * /// </summary>
         * /// <param name="x">
         * /// Value to format.
         * /// </param>
         * /// <param name="precision">
         * /// Maximum number of digits to print. May be None if unique is
         * /// True, but must be an integer if unique is False.
         * /// </param>
         * /// <param name="unique">
         * /// If True, use a digit-generation strategy which gives the shortest
         * /// representation which uniquely identifies the floating-point number from
         * /// other values of the same type, by judicious rounding. If precision
         * /// was omitted, print all necessary digits, otherwise digit generation is
         * /// cut off after precision digits and the remaining value is rounded.
         * /// If False, digits are generated as if printing an infinite-precision
         * /// value and stopping after precision digits, rounding the remaining
         * /// value.
         * /// </param>
         * /// <param name="trim">
         * /// Controls post-processing trimming of trailing digits, as follows:
         * /// </param>
         * /// <param name="sign">
         * /// Whether to show the sign for positive values.
         * /// </param>
         * /// <param name="pad_left">
         * /// Pad the left side of the string with whitespace until at least that
         * /// many characters are to the left of the decimal point.
         * /// </param>
         * /// <param name="exp_digits">
         * /// Pad the exponent with zeros until it contains at least this many digits.
         * /// If omitted, the exponent will be at least 2 digits.
         * /// </param>
         * /// <returns>
         * /// The string representation of the floating point value
         * /// </returns>
         * public static string format_float_scientific(python float or numpy floating scalar x, non-negative integer or None precision = null, bool? unique = true, one of ‘k’ trim = "k", bool? sign = false, non-negative integer pad_left = null, non-negative integer exp_digits = null)
         *  => NumPy.Instance.format_float_scientific(x, precision:precision, unique:unique, trim:trim, sign:sign, pad_left:pad_left, exp_digits:exp_digits);
         */

        /// <summary>
        /// Create a memory-map to an array stored in a binary file on disk.
        ///
        /// Memory-mapped files are used for accessing small segments of large files
        /// on disk, without reading the entire file into memory.  NumPy’s
        /// memmap’s are array-like objects.  This differs from Python’s mmap
        /// module, which uses file-like objects.
        ///
        /// This subclass of ndarray has some unpleasant interactions with
        /// some operations, because it doesn’t quite fit properly as a subclass.
        /// An alternative to using this subclass is to create the mmap
        /// object yourself, then create an ndarray with ndarray.__new__ directly,
        /// passing the object created in its ‘buffer=’ parameter.
        ///
        /// This class may at some point be turned into a factory function
        /// which returns a view into an mmap buffer.
        ///
        /// Delete the memmap instance to close the memmap file.
        ///
        /// Notes
        ///
        /// The memmap object can be used anywhere an ndarray is accepted.
        /// Given a memmap fp, isinstance(fp, numpy.ndarray) returns
        /// True.
        ///
        /// Memory-mapped files cannot be larger than 2GB on 32-bit systems.
        ///
        /// When a memmap causes a file to be created or extended beyond its
        /// current size in the filesystem, the contents of the new part are
        /// unspecified. On systems with POSIX filesystem semantics, the extended
        /// part will be filled with zero bytes.
        /// </summary>
        /// <param name="filename">
        /// The file name or file object to be used as the array data buffer.
        /// </param>
        /// <param name="dtype">
        /// The data-type used to interpret the file contents.
        /// Default is uint8.
        /// </param>
        /// <param name="mode">
        /// The file is opened in this mode:
        ///
        /// Default is ‘r+’.
        /// </param>
        /// <param name="offset">
        /// In the file, array data starts at this offset. Since offset is
        /// measured in bytes, it should normally be a multiple of the byte-size
        /// of dtype. When mode != 'r', even positive offsets beyond end of
        /// file are valid; The file will be extended to accommodate the
        /// additional data. By default, memmap will start at the beginning of
        /// the file, even if filename is a file pointer fp and
        /// fp.tell() != 0.
        /// </param>
        /// <param name="shape">
        /// The desired shape of the array. If mode == 'r' and the number
        /// of remaining bytes after offset is not a multiple of the byte-size
        /// of dtype, you must specify shape. By default, the returned array
        /// will be 1-D with the number of elements determined by file size
        /// and data-type.
        /// </param>
        /// <param name="order">
        /// Specify the order of the ndarray memory layout:
        /// row-major, C-style or column-major,
        /// Fortran-style.  This only has an effect if the shape is
        /// greater than 1-D.  The default order is ‘C’.
        /// </param>
        public static void memmap(string filename, Dtype dtype = null, string mode = null, int?offset = null, Shape shape = null, string order = null)
        => NumPy.Instance.memmap(filename, dtype: dtype, mode: mode, offset: offset, shape: shape, order: order);
Exemplo n.º 11
0
        /*
         * /// <summary>
         * /// Load data from a text file, with missing values handled as specified.
         * ///
         * /// Each line past the first skip_header lines is split at the delimiter
         * /// character, and characters following the comments character are discarded.
         * ///
         * /// Notes
         * ///
         * /// References
         * /// </summary>
         * /// <param name="fname">
         * /// File, filename, list, or generator to read.  If the filename
         * /// extension is gz or bz2, the file is first decompressed. Note
         * /// that generators must return byte strings in Python 3k.  The strings
         * /// in a list or produced by a generator are treated as lines.
         * /// </param>
         * /// <param name="dtype">
         * /// Data type of the resulting array.
         * /// If None, the dtypes will be determined by the contents of each
         * /// column, individually.
         * /// </param>
         * /// <param name="comments">
         * /// The character used to indicate the start of a comment.
         * /// All the characters occurring on a line after a comment are discarded
         * /// </param>
         * /// <param name="delimiter">
         * /// The string used to separate values.  By default, any consecutive
         * /// whitespaces act as delimiter.  An integer or sequence of integers
         * /// can also be provided as width(s) of each field.
         * /// </param>
         * /// <param name="skiprows">
         * /// skiprows was removed in numpy 1.10. Please use skip_header instead.
         * /// </param>
         * /// <param name="skip_header">
         * /// The number of lines to skip at the beginning of the file.
         * /// </param>
         * /// <param name="skip_footer">
         * /// The number of lines to skip at the end of the file.
         * /// </param>
         * /// <param name="converters">
         * /// The set of functions that convert the data of a column to a value.
         * /// The converters can also be used to provide a default value
         * /// for missing data: converters = {3: lambda s: float(s or 0)}.
         * /// </param>
         * /// <param name="missing">
         * /// missing was removed in numpy 1.10. Please use missing_values
         * /// instead.
         * /// </param>
         * /// <param name="missing_values">
         * /// The set of strings corresponding to missing data.
         * /// </param>
         * /// <param name="filling_values">
         * /// The set of values to be used as default when the data are missing.
         * /// </param>
         * /// <param name="usecols">
         * /// Which columns to read, with 0 being the first.  For example,
         * /// usecols = (1, 4, 5) will extract the 2nd, 5th and 6th columns.
         * /// </param>
         * /// <param name="names">
         * /// If names is True, the field names are read from the first line after
         * /// the first skip_header lines.  This line can optionally be proceeded
         * /// by a comment delimiter. If names is a sequence or a single-string of
         * /// comma-separated names, the names will be used to define the field names
         * /// in a structured dtype. If names is None, the names of the dtype
         * /// fields will be used, if any.
         * /// </param>
         * /// <param name="excludelist">
         * /// A list of names to exclude. This list is appended to the default list
         * /// [‘return’,’file’,’print’]. Excluded names are appended an underscore:
         * /// for example, file would become file_.
         * /// </param>
         * /// <param name="deletechars">
         * /// A string combining invalid characters that must be deleted from the
         * /// names.
         * /// </param>
         * /// <param name="defaultfmt">
         * /// A format used to define default field names, such as “f%i” or “f_%02i”.
         * /// </param>
         * /// <param name="autostrip">
         * /// Whether to automatically strip white spaces from the variables.
         * /// </param>
         * /// <param name="replace_space">
         * /// Character(s) used in replacement of white spaces in the variables
         * /// names. By default, use a ‘_’.
         * /// </param>
         * /// <param name="case_sensitive">
         * /// If True, field names are case sensitive.
         * /// If False or ‘upper’, field names are converted to upper case.
         * /// If ‘lower’, field names are converted to lower case.
         * /// </param>
         * /// <param name="unpack">
         * /// If True, the returned array is transposed, so that arguments may be
         * /// unpacked using x, y, z = loadtxt(...)
         * /// </param>
         * /// <param name="usemask">
         * /// If True, return a masked array.
         * /// If False, return a regular array.
         * /// </param>
         * /// <param name="loose">
         * /// If True, do not raise errors for invalid values.
         * /// </param>
         * /// <param name="invalid_raise">
         * /// If True, an exception is raised if an inconsistency is detected in the
         * /// number of columns.
         * /// If False, a warning is emitted and the offending lines are skipped.
         * /// </param>
         * /// <param name="max_rows">
         * /// The maximum number of rows to read. Must not be used with skip_footer
         * /// at the same time.  If given, the value must be at least 1. Default is
         * /// to read the entire file.
         * /// </param>
         * /// <param name="encoding">
         * /// Encoding used to decode the inputfile. Does not apply when fname is
         * /// a file object.  The special value ‘bytes’ enables backward compatibility
         * /// workarounds that ensure that you receive byte arrays when possible
         * /// and passes latin1 encoded strings to converters. Override this value to
         * /// receive unicode arrays and pass strings as input to converters.  If set
         * /// to None the system default is used. The default value is ‘bytes’.
         * /// </param>
         * /// <returns>
         * /// Data read from the text file. If usemask is True, this is a
         * /// masked array.
         * /// </returns>
         * public static NDarray genfromtxt(string fname, Dtype dtype = null, string comments = null, string delimiter = null, int? skiprows = null, int? skip_header = 0, int? skip_footer = 0, variable converters = null, variable missing = null, variable missing_values = null, variable filling_values = null, sequence usecols = null, {None names = null, sequence excludelist = null, string deletechars = null, string defaultfmt = "f%i", bool? autostrip = false, char replace_space = "_", {True case_sensitive = true, bool? unpack = null, bool? usemask = false, bool? loose = true, bool? invalid_raise = true, int? max_rows = null, string encoding = "bytes")
         *  => NumPy.Instance.genfromtxt(fname, dtype:dtype, comments:comments, delimiter:delimiter, skiprows:skiprows, skip_header:skip_header, skip_footer:skip_footer, converters:converters, missing:missing, missing_values:missing_values, filling_values:filling_values, usecols:usecols, names:names, excludelist:excludelist, deletechars:deletechars, defaultfmt:defaultfmt, autostrip:autostrip, replace_space:replace_space, case_sensitive:case_sensitive, unpack:unpack, usemask:usemask, loose:loose, invalid_raise:invalid_raise, max_rows:max_rows, encoding:encoding);
         */

        /// <summary>
        /// Construct an array from a text file, using regular expression parsing.
        ///
        /// The returned array is always a structured array, and is constructed from
        /// all matches of the regular expression in the file. Groups in the regular
        /// expression are converted to fields of the structured array.
        ///
        /// Notes
        ///
        /// Dtypes for structured arrays can be specified in several forms, but all
        /// forms specify at least the data type and field name. For details see
        /// doc.structured_arrays.
        /// </summary>
        /// <param name="file">
        /// File name or file object to read.
        /// </param>
        /// <param name="regexp">
        /// Regular expression used to parse the file.
        /// Groups in the regular expression correspond to fields in the dtype.
        /// </param>
        /// <param name="dtype">
        /// Dtype for the structured array.
        /// </param>
        /// <param name="encoding">
        /// Encoding used to decode the inputfile. Does not apply to input streams.
        /// </param>
        /// <returns>
        /// The output array, containing the part of the content of file that
        /// was matched by regexp. output is always a structured array.
        /// </returns>
        public static NDarray fromregex(string file, string regexp, Dtype dtype, string encoding = null)
        => NumPy.Instance.fromregex(file, regexp, dtype, encoding: encoding);
Exemplo n.º 12
0
 public Dtype(Dtype t) : base((PyObject)t.PyObject)
 {
 }
Exemplo n.º 13
0
 public static NDarray array(NDarray[] arrays, Dtype dtype = null, bool?copy = null, string order = null, bool?subok = null, int?ndmin = null)
 => array((IEnumerable <NDarray>)arrays, dtype, copy, order, subok, ndmin);