Skip to content

Dot product

Source code

Description

Compute the dot/inner product between two Expressions.

Usage

<Expr>$dot(other)

Arguments

other numeric or string value; accepts expression input.

Value

Expr

Examples

library("polars")

pl$DataFrame(
  a = 1:4, b = c(1, 2, 3, 4)
)$with_columns(
  pl$col("a")$dot(pl$col("b"))$alias("a dot b"),
  pl$col("a")$dot(pl$col("a"))$alias("a dot a")
)
#> shape: (4, 4)
#> ┌─────┬─────┬─────────┬─────────┐
#> │ a   ┆ b   ┆ a dot b ┆ a dot a │
#> │ --- ┆ --- ┆ ---     ┆ ---     │
#> │ i32 ┆ f64 ┆ f64     ┆ i32     │
#> ╞═════╪═════╪═════════╪═════════╡
#> │ 1   ┆ 1.0 ┆ 30.0    ┆ 30      │
#> │ 2   ┆ 2.0 ┆ 30.0    ┆ 30      │
#> │ 3   ┆ 3.0 ┆ 30.0    ┆ 30      │
#> │ 4   ┆ 4.0 ┆ 30.0    ┆ 30      │
#> └─────┴─────┴─────────┴─────────┘