_VectorOperator

it.grypho.scala.leonardo.vector._VectorOperator
sealed trait _VectorOperator extends _Expression

Shared behaviour of the six vector-calculus operators.

Each carries the field or scalar e, the ordered coordinate tuple, and the coordinate system. The coordinates are excluded from children and carried through rebuild (the scalar._Taylor convention — see the package overview), so substitute cannot rewrite the variables the answer is phrased in.

Attributes

Graph
Supertypes
trait _Expression
class Object
trait Matchable
class Any
Known subtypes
class _Curl
class _Div
class _Grad
class _Hessian
class _Jacobian
class _Laplacian
Show all

Members list

Value members

Abstract methods

def coords: Vector[_Variable]

The ordered coordinate tuple; free in the result, never substituted.

The ordered coordinate tuple; free in the result, never substituted.

Attributes

def e: _Expression

The scalar field or vector field the operator is applied to.

The scalar field or vector field the operator is applied to.

Attributes

protected def opName: String

The operator's own name, for toString.

The operator's own name, for toString.

Attributes

The coordinate system; only Cartesian evaluates today.

The coordinate system; only Cartesian evaluates today.

Attributes

Concrete methods

override def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

Definition Classes
protected def column(cs: Vector[_Expression]): _Matrix

Builds a column vector from its components, simplified.

Builds a column vector from its components, simplified.

Attributes

protected def componentsOf(x: _Expression, env: Environment): Option[Vector[_Expression]]

Reads e as an n×1 vector field: its components, or None when it is not one.

Reads e as an n×1 vector field: its components, or None when it is not one.

A literal matrix is read without evaluating it, and that ordering is load-bearing: the components must be differentiated before any point is substituted. Evaluating first would collapse [[x^2], [y^3]] to a dense _MatrixValue as soon as the coordinates happen to be bound — every cell a constant, every derivative zero, and a confidently wrong answer rather than a refusal.

Only a non-literal argument is evaluated, which covers the variable-bound-to-a-matrix case (the general lesson that matrix-vs-scalar cannot always be decided at parse time). An Environment holds _Values, so such a binding is necessarily a dense _MatrixValue: its cells are constants and their derivatives are legitimately zero.

A field is a column (n×1); a row vector is a different object and is refused.

Attributes

protected def d(x: _Expression, i: Int): _Expression

∂x/∂coords(i), simplified.

∂x/∂coords(i), simplified.

Attributes

protected def h: Vector[_Expression]

The scale factors, or an empty vector when the request is ill-posed (guarded by wellPosed at every use site).

The scale factors, or an empty vector when the request is ill-posed (guarded by wellPosed at every use site).

Attributes

protected def handedness: Int

Orientation of the ordered basis: +1 right-handed, -1 left-handed.

Orientation of the ordered basis: +1 right-handed, -1 left-handed.

Only curl reads this, and it must. The curl formula below is derived for a right-handed (q₁, q₂, q₃); SphericalMaths exchanges the last two coordinates of Spherical, and swapping two basis vectors flips the orientation, so the same formula returns −curl there. grad, div and laplacian involve no cross product and are orientation-free, which is why the sign lives here rather than in each operator.

Attributes

protected def jacobianFactor: _Expression

The Jacobian factor h₁·h₂·…, the volume element's coefficient.

The Jacobian factor h₁·h₂·…, the volume element's coefficient.

Attributes

protected def scaleFactors: Option[Vector[_Expression]]

The scale factors (h₁, h₂, …) for this coordinate system and tuple.

The scale factors (h₁, h₂, …) for this coordinate system and tuple.

Every operator below is written once, in terms of these; Cartesian is the h = 1 case, which is why generalising the formulas left its results untouched. None when the system cannot describe this tuple — cylindrical and spherical are three-dimensional, and a request in any other arity is refused rather than answered in the wrong geometry.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
protected def total(terms: Vector[_Expression]): _Expression

Sums a list of terms, folding to 0 when empty.

Sums a list of terms, folding to 0 when empty.

Attributes

protected def wellPosed: Boolean

True when the request is one this tier can answer at all: a coordinate tuple with no repeats, in an arity the coordinate system supports. grad(f, x, x) names no basis and is refused rather than silently producing a duplicated component.

True when the request is one this tier can answer at all: a coordinate tuple with no repeats, in an arity the coordinate system supports. grad(f, x, x) names no basis and is refused rather than silently producing a duplicated component.

Attributes

Inherited and Abstract methods

def eval(env: Environment): Either[_Expression, _Value]

Reduces this expression in the given environment.

Reduces this expression in the given environment.

Value parameters

env

variable bindings and display precision

Attributes

Returns

Right(v) when all free variables resolved to concrete values; Left(e) when reduction is partial or impossible

Inherited from:
_Expression
def rebuild(newChildren: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Inherited from:
_Expression

Inherited fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes

Inherited from:
_Expression