GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
gcd.cc File Reference
#include "dNDArray.h"
#include "CNDArray.h"
#include "fNDArray.h"
#include "fCNDArray.h"
#include "lo-mappers.h"
#include "oct-binmap.h"
#include "defun.h"
#include "error.h"
#include "ovl.h"
Include dependency graph for gcd.cc:

Go to the source code of this file.

Macros

#define MAKE_INT_BRANCH(X)
 
#define MAKE_INT_BRANCH(X)
 

Functions

template<typename FP >
static void divide (const std::complex< FP > &a, const std::complex< FP > &b, std::complex< FP > &q, std::complex< FP > &r)
 
template<typename NDA >
static octave_value do_extended_gcd (const octave_value &a, const octave_value &b, octave_value &x, octave_value &y)
 
template<typename NDA >
static octave_value do_simple_gcd (const octave_value &a, const octave_value &b)
 
template<typename T >
static octave_int< T > extended_gcd (const octave_int< T > &a, const octave_int< T > &b, octave_int< T > &x, octave_int< T > &y)
 
template<typename FP >
static std::complex< FP > extended_gcd (const std::complex< FP > &a, const std::complex< FP > &b, std::complex< FP > &x, std::complex< FP > &y)
 
static double extended_gcd (double a, double b, double &x, double &y)
 
OCTAVE_EXPORT octave_value_list Fgcd (const octave_value_list &args, int nargout)
 
template<typename T >
static octave_int< T > simple_gcd (const octave_int< T > &a, const octave_int< T > &b)
 
template<typename FP >
static std::complex< FP > simple_gcd (const std::complex< FP > &a, const std::complex< FP > &b)
 
static double simple_gcd (double a, double b)
 

Macro Definition Documentation

◆ MAKE_INT_BRANCH [1/2]

#define MAKE_INT_BRANCH (   X)
Value:
case btyp_ ## X: \
retval = do_simple_gcd<X ## NDArray> (a, b); \
break

◆ MAKE_INT_BRANCH [2/2]

#define MAKE_INT_BRANCH (   X)
Value:
case btyp_ ## X: \
retval = do_extended_gcd<X ## NDArray> (a, b, x, y); \
break
F77_RET_T const F77_DBLE * x

Function Documentation

◆ divide()

template<typename FP >
static void divide ( const std::complex< FP > &  a,
const std::complex< FP > &  b,
std::complex< FP > &  q,
std::complex< FP > &  r 
)
static

Definition at line 65 of file gcd.cc.

References octave::math::floor(), imag(), r, and real().

Referenced by extended_gcd(), and simple_gcd().

◆ do_extended_gcd()

template<typename NDA >
static octave_value do_extended_gcd ( const octave_value a,
const octave_value b,
octave_value x,
octave_value y 
)
static

Definition at line 320 of file gcd.cc.

References octave_value::dims(), octave::err_nonconformant(), extended_gcd(), octave_value::is_scalar_type(), n, retval, and x.

Referenced by Fgcd().

◆ do_simple_gcd()

template<typename NDA >
static octave_value do_simple_gcd ( const octave_value a,
const octave_value b 
)
static

Definition at line 240 of file gcd.cc.

References octave_value::is_scalar_type(), retval, and simple_gcd().

Referenced by Fgcd().

◆ extended_gcd() [1/3]

template<typename T >
static octave_int<T> extended_gcd ( const octave_int< T > &  a,
const octave_int< T > &  b,
octave_int< T > &  x,
octave_int< T > &  y 
)
static

Definition at line 207 of file gcd.cc.

References octave_int< T >::abs(), octave_int< T >::signum(), and x.

◆ extended_gcd() [2/3]

template<typename FP >
static std::complex<FP> extended_gcd ( const std::complex< FP > &  a,
const std::complex< FP > &  b,
std::complex< FP > &  x,
std::complex< FP > &  y 
)
static

Definition at line 158 of file gcd.cc.

References abs(), divide(), error(), octave::math::isinteger(), and x.

◆ extended_gcd() [3/3]

static double extended_gcd ( double  a,
double  b,
double &  x,
double &  y 
)
static

Definition at line 121 of file gcd.cc.

References error(), octave::math::floor(), octave::math::isinteger(), and x.

Referenced by do_extended_gcd().

◆ Fgcd()

OCTAVE_EXPORT octave_value_list Fgcd ( const octave_value_list args,
int  nargout 
)

◆ simple_gcd() [1/3]

template<typename T >
static octave_int<T> simple_gcd ( const octave_int< T > &  a,
const octave_int< T > &  b 
)
static

Definition at line 105 of file gcd.cc.

References octave_int< T >::abs().

◆ simple_gcd() [2/3]

template<typename FP >
static std::complex<FP> simple_gcd ( const std::complex< FP > &  a,
const std::complex< FP > &  b 
)
static

Definition at line 78 of file gcd.cc.

References abs(), divide(), error(), and octave::math::isinteger().

◆ simple_gcd() [3/3]

static double simple_gcd ( double  a,
double  b 
)
static

Definition at line 42 of file gcd.cc.

References error(), and octave::math::isinteger().

Referenced by do_simple_gcd().