51 template <
class R,
class T>
55 assert (a.
ndims () == 2);
56 assert (b.
ndims () == 2);
78 template <
class R,
class T>
82 assert (b.
ndims () == 2);
120 const T v = A.
data (Ai);
124 C.data (idx) = v * B.
data (Bi);
125 C.ridx (idx++) = Ci + B.
ridx (Bi);
128 C.cidx (Aj * B.
columns () + Bj + 1) = idx;
147 res_perm.
xelem (rescol++) = a_add + pb(j);
153 template <
class MTA,
class MTB>
157 MTA am = octave_value_extract<MTA> (a);
158 MTB bm = octave_value_extract<MTB> (b);
167 retval = do_kron<PermMatrix, PermMatrix> (a, b);
171 retval = do_kron<SparseComplexMatrix, SparseComplexMatrix> (a, b);
173 retval = do_kron<SparseMatrix, SparseMatrix> (a, b);
191 retval = tmp.
diag ();
196 retval = do_kron<FloatComplexDiagMatrix, FloatComplexMatrix> (a, b);
198 retval = do_kron<FloatDiagMatrix, FloatComplexMatrix> (a, b);
200 retval = do_kron<FloatDiagMatrix, FloatMatrix> (a, b);
205 retval = do_kron<ComplexDiagMatrix, ComplexMatrix> (a, b);
207 retval = do_kron<DiagMatrix, ComplexMatrix> (a, b);
209 retval = do_kron<DiagMatrix, Matrix> (a, b);
215 retval = do_kron<FloatComplexMatrix, FloatComplexMatrix> (a, b);
217 retval = do_kron<FloatMatrix, FloatComplexMatrix> (a, b);
219 retval = do_kron<FloatMatrix, FloatMatrix> (a, b);
224 retval = do_kron<ComplexMatrix, ComplexMatrix> (a, b);
226 retval = do_kron<Matrix, ComplexMatrix> (a, b);
228 retval = do_kron<Matrix, Matrix> (a, b);
235 @deftypefn {Built-in Function} {} kron (@var{A}, @var{B})\n\
236 @deftypefnx {Built-in Function} {} kron (@var{A1}, @var{A2}, @dots{})\n\
237 Form the Kronecker product of two or more matrices.\n\
239 This is defined block by block as\n\
249 kron (1:4, ones (3, 1))\n\
256 If there are more than two input arguments @var{A1}, @var{A2}, @dots{},\n\
257 @var{An} the Kronecker product is computed as\n\
260 kron (kron (@var{A1}, @var{A2}), @dots{}, @var{An})\n\
264 Since the Kronecker product is associative, this is well-defined.\n\
269 int nargin = args.
length ();
octave_value dispatch_kron(const octave_value &a, const octave_value &b)
octave_idx_type rows(void) const
octave_idx_type rows(void) const
octave_idx_type rows(void) const
OCTINTERP_API void print_usage(void)
octave_value diag(octave_idx_type k=0) const
F77_RET_T const octave_idx_type Complex * A
#define DEFUN(name, args_name, nargout_name, doc)
bool is_perm_matrix(void) const
octave_idx_type rows(void) const
octave_idx_type * cidx(void)
octave_idx_type columns(void) const
octave_idx_type rows(void) const
void mx_inline_mul(size_t n, R *r, const X *x, const Y *y)
octave_idx_type nnz(void) const
T dgelem(octave_idx_type i) const
octave_idx_type columns(void) const
bool is_sparse_type(void) const
const Array< octave_idx_type > & col_perm_vec(void) const
const T * data(void) const
bool is_complex_type(void) const
octave_idx_type length(void) const
static MArray< T > kron(const MArray< R > &a, const MArray< T > &b)
T & xelem(octave_idx_type n)
octave_idx_type cols(void) const
octave_idx_type * ridx(void)
F77_RET_T const octave_idx_type Complex const octave_idx_type Complex * B
octave_value do_kron(const octave_value &a, const octave_value &b)
octave_idx_type diag_length(void) const
const T * fortran_vec(void) const
bool is_single_type(void) const
octave_idx_type cols(void) const
bool is_diag_matrix(void) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))