This commit is contained in:
CismonX 2019-04-13 18:17:01 +08:00
parent 091b735eb8
commit 3e31b779e5
9 changed files with 833 additions and 72 deletions

View File

@ -19,7 +19,7 @@ namespace php_arma
void base_init();
constexpr const char base_php_name[] = "Internal\\Base";
constexpr const char base_php_name[] = "Base";
inline zend_class_entry *base_ce;
}

View File

@ -49,6 +49,309 @@ namespace php_arma
current->handlers = &handlers;
}
template <typename T>
PHP_ARMA_METHOD(complex, fromPolar, T)
{
zval *r, *theta;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL(r)
Z_PARAM_ZVAL(theta)
ZEND_PARSE_PARAMETERS_END();
if (!zval_check_scalar<T>(r)) {
return;
}
if (!zval_check_scalar<T>(theta)) {
return;
}
auto retval = std::polar(zval_get_scalar<T>(r), zval_get_scalar<T>(theta));
zval_set_scalar(return_value, retval);
}
template <typename T>
PHP_ARMA_METHOD(complex, add, T)
{
zval *other;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(other)
ZEND_PARSE_PARAMETERS_END();
auto current = zval_get_scalar<native_t>(getThis());
if (zval_is_scalar<native_t>(other)) {
zval_set_scalar(return_value, current + zval_get_scalar<native_t>(other));
return;
}
if (zval_is_scalar<T>(other)) {
zval_set_scalar(return_value, current + zval_get_scalar<T>(other));
return;
}
ex_bad_type<T>(other);
}
template <typename T>
PHP_ARMA_METHOD(complex, sub, T)
{
zval *other;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(other)
ZEND_PARSE_PARAMETERS_END();
auto current = zval_get_scalar<native_t>(getThis());
if (zval_is_scalar<native_t>(other)) {
zval_set_scalar(return_value, current - zval_get_scalar<native_t>(other));
return;
}
if (zval_is_scalar<T>(other)) {
zval_set_scalar(return_value, current - zval_get_scalar<T>(other));
return;
}
ex_bad_type<T>(other);
}
template <typename T>
PHP_ARMA_METHOD(complex, neg, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, -current);
}
template <typename T>
PHP_ARMA_METHOD(complex, mul, T)
{
zval *other;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(other)
ZEND_PARSE_PARAMETERS_END();
auto current = zval_get_scalar<native_t>(getThis());
if (zval_is_scalar<native_t>(other)) {
zval_set_scalar(return_value, current * zval_get_scalar<native_t>(other));
return;
}
if (zval_is_scalar<T>(other)) {
zval_set_scalar(return_value, current * zval_get_scalar<T>(other));
return;
}
ex_bad_type<T>(other);
}
template <typename T>
PHP_ARMA_METHOD(complex, div, T)
{
zval *other;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(other)
ZEND_PARSE_PARAMETERS_END();
auto current = zval_get_scalar<native_t>(getThis());
if (zval_is_scalar<native_t>(other)) {
zval_set_scalar(return_value, current / zval_get_scalar<native_t>(other));
return;
}
if (zval_is_scalar<T>(other)) {
zval_set_scalar(return_value, current / zval_get_scalar<T>(other));
return;
}
ex_bad_type<T>(other);
}
template <typename T>
PHP_ARMA_METHOD(complex, abs, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::abs(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, arg, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::arg(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, norm, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::norm(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, conj, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::conj(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, exp, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::exp(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, log, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::log(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, log10, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::log10(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, pow, T)
{
zval *other;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(other)
ZEND_PARSE_PARAMETERS_END();
auto current = zval_get_scalar<native_t>(getThis());
if (zval_is_scalar<native_t>(other)) {
zval_set_scalar(return_value, std::pow(current, zval_get_scalar<native_t>(other)));
return;
}
if (zval_is_scalar<T>(other)) {
zval_set_scalar(return_value, std::pow(current, zval_get_scalar<T>(other)));
return;
}
ex_bad_type<T>(other);
}
template <typename T>
PHP_ARMA_METHOD(complex, sqrt, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::abs(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, sin, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::sin(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, cos, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::cos(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, tan, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::tan(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, asin, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::asin(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, acos, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::acos(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, atan, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::atan(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, sinh, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::sinh(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, cosh, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::cosh(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, tanh, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::tanh(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, asinh, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::asinh(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, acosh, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::acosh(current));
}
template <typename T>
PHP_ARMA_METHOD(complex, atanh, T)
{
auto current = zval_get_scalar<native_t>(getThis());
zval_set_scalar(return_value, std::atanh(current));
}
template <typename T>
void complex<T>::write_property(zval *obj, zval *member, zval *value, void **unused)
{
@ -74,6 +377,57 @@ namespace php_arma
"Bad property name for %s, expected 'real' or 'imag', '%s' given.", Z_OBJNAME_P(obj), Z_STRVAL_P(member));
}
template <typename T>
int complex<T>::compare_objects(zval *zv1, zval *zv2)
{
auto zobj1 = Z_OBJ_P(zv1);
auto zobj2 = Z_OBJ_P(zv2);
if (zobj1 == zobj2) {
return 0;
}
if (UNEXPECTED(zobj1->ce != zobj2->ce)) {
return 1;
}
auto v1 = zval_get_scalar<native_t>(zv1);
auto v2 = zval_get_scalar<native_t>(zv2);
return v1 != v2;
}
template <typename T>
PHP_ARMA_START_ME(complex, T)
PHP_ARMA_ME(__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ARMA_ME(fromPolar, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ARMA_ME(add, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(sub, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(neg, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(mul, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(div, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(abs, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(arg, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(norm, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(conj, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(exp, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(log, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(log10, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(pow, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(sqrt, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(sin, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(cos, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(tan, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(asin, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(acos, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(atan, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(sinh, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(cosh, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(tanh, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(asinh, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(acosh, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(atanh, ZEND_ACC_PUBLIC)
PHP_ARMA_END_ME();
template <typename T>
zend_always_inline
void complex<T>::ce_init(zend_class_entry *parent_ce)
@ -83,6 +437,7 @@ namespace php_arma
property_declare<T>(ce, "imag");
object_handlers_init(&handlers);
handlers.write_property = write_property;
handlers.compare_objects = compare_objects;
}
PHP_ARMA_NAME_DECLARE(complex, "CxDouble", double);

View File

@ -18,22 +18,48 @@ namespace php_arma
template <typename T>
struct complex
{
using native_t = std::complex<T>;
friend void complex_init();
PHP_ARMA_CE_HANDLRES_DECLARE();
private:
struct php_name;
PHP_ARMA_COMMON_DECLARE();
static PHP_FUNCTION(__construct);
static PHP_FUNCTION(fromPolar);
static PHP_FUNCTION(add);
static PHP_FUNCTION(sub);
static PHP_FUNCTION(neg);
static PHP_FUNCTION(mul);
static PHP_FUNCTION(div);
static PHP_FUNCTION(abs);
static PHP_FUNCTION(arg);
static PHP_FUNCTION(norm);
static PHP_FUNCTION(conj);
static PHP_FUNCTION(exp);
static PHP_FUNCTION(log);
static PHP_FUNCTION(log10);
static PHP_FUNCTION(pow);
static PHP_FUNCTION(sqrt);
static PHP_FUNCTION(sin);
static PHP_FUNCTION(cos);
static PHP_FUNCTION(tan);
static PHP_FUNCTION(asin);
static PHP_FUNCTION(acos);
static PHP_FUNCTION(atan);
static PHP_FUNCTION(sinh);
static PHP_FUNCTION(cosh);
static PHP_FUNCTION(tanh);
static PHP_FUNCTION(asinh);
static PHP_FUNCTION(acosh);
static PHP_FUNCTION(atanh);
static void write_property(zval*, zval*, zval*, void**);
static int compare_objects(zval*, zval*);
static void ce_init(zend_class_entry*);
PHP_ARMA_START_ME()
PHP_ARMA_ME(__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ARMA_END_ME();
};
void complex_init();
@ -76,6 +102,18 @@ namespace php_arma
zval_ptr_dtor(zv);
ZVAL_OBJ(zv, zobj);
}
template <typename T>
zend_always_inline
void ex_bad_type(zval *zv) {
auto real_type_name = scalar_type_name<T>();
auto complex_type_name = scalar_type_name<typename complex<T>::native_t>();
auto expected = (char*)malloc((strlen(real_type_name) + strlen(complex_type_name) + 5) * sizeof(char));
sprintf(expected, "%s or %s", real_type_name, complex_type_name);
auto got = Z_TYPE_P(zv) == IS_OBJECT ? Z_OBJNAME_P(zv) : zend_get_type_by_const(Z_TYPE_P(zv));
ex_bad_type(expected, got);
free(expected);
}
}
#endif // !PHP_ARMA_COMPLEX_HH

View File

@ -45,6 +45,12 @@ namespace php_arma
set_val(current, zval_get_scalar<T>(val));
}
template <typename T, bool B1, bool B2>
PHP_ARMA_START_ME(mapval, T, B1, B2)
PHP_ARMA_ME(val, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(setTo, ZEND_ACC_PUBLIC)
PHP_ARMA_END_ME();
template <typename T, bool B1, bool B2>
zend_always_inline
void mapval<T, B1, B2>::ce_init(zend_class_entry *parent_ce)

View File

@ -60,7 +60,7 @@ namespace php_arma
PHP_ARMA_CE_HANDLRES_DECLARE();
private:
struct php_name;
PHP_ARMA_COMMON_DECLARE();
static PHP_FUNCTION(val);
static PHP_FUNCTION(setTo);
@ -68,11 +68,6 @@ namespace php_arma
static T get_val(zend_object*);
static void ce_init(zend_class_entry*);
PHP_ARMA_START_ME()
PHP_ARMA_ME(val, ZEND_ACC_PUBLIC)
PHP_ARMA_ME(setTo, ZEND_ACC_PUBLIC)
PHP_ARMA_END_ME();
};
template <typename T>
@ -86,7 +81,7 @@ namespace php_arma
void mapval_init();
constexpr const char scalar_php_name[] = "Internal\\Scalar";
constexpr const char scalar_php_name[] = "Scalar";
constexpr const char mapval_php_name[] = "MapVal";
constexpr const char sp_mapval_php_name[] = "SpMapVal";
constexpr const char spsv_mapval_php_name[] = "SpSvMapVal";

View File

@ -26,8 +26,8 @@ extern zend_module_entry arma_module_entry;
/// Helper macros for method entry.
#define PHP_ARMA_START_ME() \
static constexpr zend_function_entry const me[] = {
#define PHP_ARMA_START_ME(cls, ...) \
zend_function_entry cls<__VA_ARGS__>::me[] = {
#define PHP_ARMA_END_ME() \
PHP_FE_END \
@ -54,6 +54,10 @@ extern zend_module_entry arma_module_entry;
#define Z_OBJNAME_P(zval_p) \
ZSTR_VAL(Z_OBJCE_P(zval_p)->name)
#define PHP_ARMA_COMMON_DECLARE() \
struct php_name; \
static zend_function_entry me[]
#define PHP_ARMA_NAME_DECLARE(cls, name, ...) \
template <> \
struct cls<__VA_ARGS__>::php_name \
@ -67,10 +71,10 @@ namespace php_arma
namespace str
{
template <size_t... S>
using size = std::integer_sequence<size_t, S...>;
using seq = std::integer_sequence<size_t, S...>;
template <size_t N>
using get_size = std::make_integer_sequence<size_t, N>;
using seq_impl = std::make_integer_sequence<size_t, N>;
constexpr auto get_len(const char *str)
{
@ -83,7 +87,7 @@ namespace php_arma
struct concat_impl;
template <const char* Str1, size_t... Len1, const char* Str2, size_t... Len2>
struct concat_impl<Str1, size<Len1...>, Str2, size<Len2...>>
struct concat_impl<Str1, seq<Len1...>, Str2, seq<Len2...>>
{
static constexpr const char value[]
{
@ -94,16 +98,23 @@ namespace php_arma
template <const char *Str1, const char *Str2>
constexpr auto concat
{
concat_impl<Str1, get_size<get_len(Str1)>, Str2, get_size<get_len(Str2)>>::value
concat_impl<Str1, seq_impl<get_len(Str1)>, Str2, seq_impl<get_len(Str2)>>::value
};
constexpr const char namespace_prefix[] = "Arma\\";
constexpr const char internal_prefix[] = "Internal\\";
template <const char *Str>
constexpr auto with_arma_prefix
{
concat<namespace_prefix, Str>
};
template <const char *Str>
constexpr auto with_internal_prefix
{
concat<internal_prefix, Str>
};
}
/// Helper functions for initializing class entry and object handlers.
@ -134,14 +145,14 @@ namespace php_arma
{
// Although methods are declared in interfaces as you see in the stubs,
// nothing is declared in the internal interface implementation.
return ce_init<Name>(nullptr, zend_register_internal_class);
return ce_init<str::with_internal_prefix<Name>>(nullptr, zend_register_internal_class);
}
template <const char *Name, typename... Ts>
zend_always_inline
zend_class_entry *interface_register(Ts... parents)
{
return ce_init<Name>(nullptr, zend_register_internal_class, parents...);
return ce_init<str::with_internal_prefix<Name>>(nullptr, zend_register_internal_class, parents...);
}
template <const char *Name>

View File

@ -29,5 +29,211 @@ abstract class Complex
* @param number $real[optional]
* @param number $imag[optional]
*/
abstract function __construct($real, $imag);
function __construct($real, $imag) {}
/**
* Returns a complex number with magnitude r and phase angle theta.
*
* @param number $r : magnitude
* @param number $theta : phase angle
* @return static
*/
static function fromPolar($r, $theta) {}
// Arithmetic functions
/**
* Addition of two complex numbers.
*
* @param number|static $other
* @return static
*/
function add($other) {}
/**
* Subtraction of two complex numbers.
*
* @param number|static $other
* @return static
*/
function sub($other) {}
/**
* Negation of the complex number.
*
* @return static
*/
function neg() {}
/**
* Multiplication of two complex numbers.
*
* @param number|static $other
* @return static
*/
function mul($other) {}
/**
* Division of two complex numbers.
*
* @param number|static $other
* @return static
*/
function div($other) {}
/**
* Returns the magnitude of the complex number.
*
* @return number
*/
function abs() {}
/**
* Returns the phase angle of the complex number.
*
* @return number
*/
function arg() {}
/**
* Returns the squared magnitude of the complex number.
*
* @return number
*/
function norm() {}
/**
* Returns the complex conjugate.
*
* @return static
*/
function conj() {}
// Exponential functions
/**
* Compute base-e exponential of the complex number.
*
* @return static
*/
function exp() {}
/**
* Complex natural logarithm with the branch cuts along the negative real axis.
*
* @return static
*/
function log() {}
/**
* Complex common logarithm with the branch cuts along the negative real axis.
*
* @return static
*/
function log10() {}
// Power functions
/**
* Computes complex power.
*
* @param number|static $other
* @return static
*/
function pow($other) {}
/**
* Complex square root in the range of the right half-plane.
*
* @return number
*/
function sqrt() {}
// Trigonometric functions
/**
* Computes sine of the complex number.
*
* @return static
*/
function sin() {}
/**
* Computes cosine of the complex number.
*
* @return static
*/
function cos() {}
/**
* Computes tangent of the complex number.
*
* @return static
*/
function tan() {}
/**
* Computes arc sine of the complex number.
*
* @return static
*/
function asin() {}
/**
* Computes arc cosine of the complex number.
*
* @return static
*/
function acos() {}
/**
* Computes arc tangent of the complex number.
*
* @return static
*/
function atan() {}
// Hyperbolic functions
/**
* Computes hyperbolic sine of the complex number.
*
* @return static
*/
function sinh() {}
/**
* Computes hyperbolic cosine of the complex number.
*
* @return static
*/
function cosh() {}
/**
* Computes hyperbolic tangent of the complex number.
*
* @return static
*/
function tanh() {}
/**
* Computes area hyperbolic sine of the complex number.
*
* @return static
*/
function asinh() {}
/**
* Computes area hyperbolic cosine of the complex number.
*
* @return static
*/
function acosh() {}
/**
* Computes area hyperbolic tangent of the complex number.
*
* @return static
*/
function atanh() {}
}

View File

@ -10,11 +10,15 @@ namespace Arma;
class CxDouble extends Complex
{
/**
* {@inheritdoc}
*
* @var double
*/
public $real;
/**
* {@inheritdoc}
*
* @var double
*/
public $imag;
@ -26,4 +30,200 @@ class CxDouble extends Complex
* @param double $imag[optional]
*/
function __construct($real = 0.0, $imag = 0.0) {}
/**
* {@inheritdoc}
*
* @param double $r : magnitude
* @param double $theta : phase angle
* @return CxDouble
*/
static function fromPolar($r, $theta) {}
/**
* {@inheritdoc}
*
* @param double|CxDouble $other
* @return CxDouble
*/
function add($other) {}
/**
* {@inheritdoc}
*
* @param double|CxDouble $other
* @return CxDouble
*/
function sub($other) {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function neg() {}
/**
* {@inheritdoc}
*
* @param double|CxDouble $other
* @return CxDouble
*/
function mul($other) {}
/**
* {@inheritdoc}
*
* @param double|CxDouble $other
* @return CxDouble
*/
function div($other) {}
/**
* {@inheritdoc}
*
* @return double
*/
function abs() {}
/**
* {@inheritdoc}
*
* @return double
*/
function arg() {}
/**
* {@inheritdoc}
*
* @return double
*/
function norm() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function conj() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function exp() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function log() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function log10() {}
/**
* {@inheritdoc}
*
* @param double|CxDouble $other
* @return CxDouble
*/
function pow($other) {}
/**
* {@inheritdoc}
*
* @return double
*/
function sqrt() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function sin() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function cos() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function tan() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function asin() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function acos() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function atan() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function sinh() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function cosh() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function tanh() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function asinh() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function acosh() {}
/**
* {@inheritdoc}
*
* @return CxDouble
*/
function atanh() {}
}

View File

@ -26,16 +26,6 @@ interface Base
*/
function add($other);
/**
* Addition of two objects.
*
* Current object will be replaced by the calculation result.
*
* @param mixed $other
* @return static
*/
function addAssign($other);
/**
* Subtraction of two objects.
*
@ -44,16 +34,6 @@ interface Base
*/
function sub($other);
/**
* Subtraction of two objects.
*
* Current object will be replaced by the calculation result.
*
* @param mixed $other
* @return static
*/
function subAssign($other);
/**
* Negation of the object.
*
@ -69,16 +49,6 @@ interface Base
*/
function mul($other);
/**
* Matrix multiplication of two objects.
*
* Current object will be replaced by the calculation result.
*
* @param mixed $other
* @return static
*/
function mulAssign($other);
/**
* Element-wise multiplication of two objects.
*
@ -87,16 +57,6 @@ interface Base
*/
function dotMul($other);
/**
* Element-wise multiplication of two objects.
*
* Current object will be replaced by the calculation result.
*
* @param static $other
* @return static
*/
function dotMulAssign($other);
/**
* Element-wise division of an object by another object or a scalar.
*
@ -105,16 +65,6 @@ interface Base
*/
function div($other);
/**
* Element-wise division of an object by another object or a scalar.
*
* Current object will be replaced by the calculation result.
*
* @param mixed $other
* @return static
*/
function divAssign($other);
/**
* For all elements equal to $old_value, set them to $new_value.
*