Calling Object (self) Role Convention

The role of the calling object (self) in MtxVec operations follows three simple rules:

Rule 1: Transform operations — self is the DESTINATION

  • self.Sin(X) → reads from X, stores result in self
  • self.AddAndMul(X, Y, Z) → computes (X+Y)*Z, stores in self
  • Parameters named X, Y, Z, Vec1, Vec2, Src, Source are inputs
  • Summary pattern: "Compute ... " or "Calculate ... and store the results in calling object"

Rule 2: Scalar-returning methods — self is the SOURCE

  • result = self.Sum() → reads from self, returns scalar
  • result = self.StdDev() → reads from self, returns scalar
  • Methods: Sum, Min, Max, Norm, NormL1, NormL2, StdDev, Product, Mean, Variance
  • These never modify self.

Rule 3: In-place operations — self is BOTH source and destination

  • self.Sin() → reads from self, stores result back in self (no arguments)
  • self.Abs() → in-place absolute value
  • Pattern: 0-argument form of a transform method.

Formula convention: When a summary contains a formula like "Compute (X + Y)*Z", the named variables (X, Y, Z) are the source parameters; self receives the result.

Quick reference:

FormSelf roleExample
self.Op(X)Destinationself.Sin(X) — self = sin(X)
self.Op(X, Y)Destinationself.Add(X, Y) — self = X + Y
self.Op()Both (in-place)self.Sin() — self = sin(self)
val = self.Op()Sourceval = self.Sum() — returns sum of self