37 const octave_idx_type&,
const double*,
38 const double*,
double*);
41 F77_FUNC (
sdot3, SDOT3) (
const octave_idx_type&,
const octave_idx_type&,
42 const octave_idx_type&,
const float*,
43 const float*,
float*);
46 F77_FUNC (
zdotc3, ZDOTC3) (
const octave_idx_type&,
const octave_idx_type&,
47 const octave_idx_type&,
const Complex*,
48 const Complex*, Complex*);
51 F77_FUNC (
cdotc3, CDOTC3) (
const octave_idx_type&,
const octave_idx_type&,
53 const FloatComplex*, FloatComplex*);
56 F77_FUNC (
dmatm3, DMATM3) (
const octave_idx_type&,
const octave_idx_type&,
57 const octave_idx_type&,
const octave_idx_type&,
58 const double*,
const double*,
double*);
61 F77_FUNC (
smatm3, SMATM3) (
const octave_idx_type&,
const octave_idx_type&,
62 const octave_idx_type&,
const octave_idx_type&,
63 const float*,
const float*,
float*);
66 F77_FUNC (
zmatm3, ZMATM3) (
const octave_idx_type&,
const octave_idx_type&,
67 const octave_idx_type&,
const octave_idx_type&,
68 const Complex*,
const Complex*, Complex*);
71 F77_FUNC (
cmatm3, CMATM3) (
const octave_idx_type&,
const octave_idx_type&,
72 const octave_idx_type&,
const octave_idx_type&,
73 const FloatComplex*,
const FloatComplex*,
83 assert (nd == y.
length ());
86 for (
int i = 0; i < nd; i++)
108 @deftypefn {Built-in Function} {} dot (@var{x}, @var{y}, @var{dim})\n\
109 Compute the dot product of two vectors. If @var{x} and @var{y}\n\
110 are matrices, calculate the dot products along the first\n\
111 non-singleton dimension. If the optional argument @var{dim} is\n\
112 given, calculate the dot products along this dimension.\n\
114 This is equivalent to\n\
115 @code{sum (conj (@var{X}) .* @var{Y}, @var{dim})},\n\
116 but avoids forming a temporary array and is faster. When @var{X} and\n\
117 @var{Y} are column vectors, the result is equivalent to\n\
118 @code{@var{X}' * @var{Y}}.\n\
119 @seealso{cross, divergence}\n\
123 int nargin = args.
length ();
125 if (nargin < 2 || nargin > 3)
136 bool match = dimx == dimy;
137 if (! match && nargin == 2
138 && dimx.
is_vector () && dimy.is_vector ())
141 dimx = dimx.
redim (1);
143 dimy = dimy.redim (1);
154 dim = args(2).int_value (
true) - 1;
159 error (
"dot: DIM must be a valid dimension");
207 NDArray y = argy.array_value ();
224 tmp =
feval (
"sum", tmp, 1);
232 error (
"dot: sizes of X and Y must match");
236 error (
"dot: X and Y must be numeric");
267 DEFUN (blkmm, args, ,
269 @deftypefn {Built-in Function} {} blkmm (@var{A}, @var{B})\n\
270 Compute products of matrix blocks. The blocks are given as\n\
271 2-dimensional subarrays of the arrays @var{A}, @var{B}.\n\
272 The size of @var{A} must have the form @code{[m,k,@dots{}]} and\n\
273 size of @var{B} must be @code{[k,n,@dots{}]}. The result is\n\
274 then of size @code{[m,n,@dots{}]} and is computed as follows:\n\
278 for i = 1:prod (size (@var{A})(3:end))\n\
279 @var{C}(:,:,i) = @var{A}(:,:,i) * @var{B}(:,:,i)\n\
286 int nargin = args.
length ();
301 bool match = dimy(0) == k && nd == dimy.length ();
305 for (
int i = 2; match && i < nd; i++)
307 match = match && dimx(i) == dimy(i);
355 NDArray y = argy.array_value ();
366 error (
"blkmm: A and B dimensions don't match: (%s) and (%s)",
367 dimx.
str ().c_str (), dimy.str ().c_str ());
371 error (
"blkmm: A and B must be numeric");