```{index} single: inner (PDL) ``` ```{index} single: PDL::inner ``` # inner `inner($a, $b)` -- inner (dot) product along the first dimension. Given two ndarrays with matching first-axis length `n`, computes `c = sum_i a_i * b_i`. For 1-D inputs this is the standard dot product, a 0-dimensional result; for higher-rank inputs the contraction is over axis 0 and the remaining axes broadcast. ## Signature ```perl $c = inner($a, $b); # function form $c = $a->inner($b); # method form inner($a, $b, $c); # writes into $c, returns nothing ``` ## Bad values If any element of `$a` or `$b` along the first dimension is bad, that result is bad. ## Examples ```perl use PDL; my $a = pdl([1, 2, 3]); my $b = pdl([4, 5, 6]); print inner($a, $b); # 32 (1*4 + 2*5 + 3*6) print $a->inner($b); # 32 (method form) # Scalar-on-vector also works (scalar broadcasts to each element) print inner(pdl([1, 2, 3]), 2); # 12 (1*2 + 2*2 + 3*2) ``` ## Errors Croaks when the dimensions do not match, or with the usage when given fewer than two or more than three arguments.