scalars

Containing classes for various scalars. Used for example as output when taking inner-product of states. In particular when the output is not a number but a symbolic variable of function.

qualg.scalars.is_number(n)

Check if something is a number (int, float or complex)

qualg.scalars.is_scalar(n)

Check if something is considered a scalar (number of Scalar)

class qualg.scalars.Scalar

Base-class for all scalars.

Meant to be subclassed.

has_variable(variable)

Checks if scalar depends on a given variable.

get_variables()

Returns the variable of this operator.

abstract conjugate()

Complex conjugate

class qualg.scalars.Variable(variable, conjugate=False)
__init__(variable, conjugate=False)

Represents a number as a variable

Parameters
  • variable (str) – Name of variable.

  • (optional) (conjugate) – If the variable is conjugated (default: False)

conjugate()

Complex conjugate

is_zero()
is_one()
class qualg.scalars.AbsoluteVariable(variable)
__init__(variable)

Represents the absolute value squared of a variable

Parameters

variable (str) – Name of variable.

conjugate()

Complex conjugate

is_zero()
is_one()
class qualg.scalars.SingleVarFunctionScalar(func_name, variable, conjugate=False)
__init__(func_name, variable, conjugate=False)

Represents a function with a single symbolic variable, e.g. f(x).

Parameters
  • func_name (str) – Name of function.

  • variable (str) – Name of variable.

  • (optional) (conjugate) – If the functions is conjugated (default: False)

conjugate()

Complex conjugate

replace_var(old_variable, new_variable)
get_variables()

Returns the variable of this operator.

is_zero()
is_one()
has_variable(variable)

Checks if scalar depends on a given variable.

class qualg.scalars.InnerProductFunction(func_name1, func_name2)
__init__(func_name1, func_name2)

Represents the inner product of two functions.

Parameters
  • func_name1 (str) – Name of first function

  • func_name2 (str) – Name of second function

conjugate()

Complex conjugate

is_zero()
is_one()
class qualg.scalars.DeltaFunction(var1, var2)
__init__(var1, var2)

Delta function between two variables, e.g. d(x - y)

Parameters
  • var1 (str) – First variable

  • var2 (str) – First variable

conjugate()

Complex conjugate

replace_var(old_variable, new_variable)
get_variables()

Returns the variable of this operator.

is_zero()
is_one()
has_variable(variable)

Checks if scalar depends on a given variable.

class qualg.scalars.ProductOfScalars(scalars=None)
__init__(scalars=None)

Product of some number of scalars.

Parameters

scalars (None or list of scalar) – The factors of the product.

conjugate()

Complex conjugate

atoms()
replace_var(old_variable, new_variable)
get_variables()

Returns the variable of this operator.

expand()
is_zero()
is_one()
simplify(full=True)
has_variable(variable)

Checks if scalar depends on a given variable.

class qualg.scalars.SumOfScalars(scalars=None)
__init__(scalars=None)

Sum of some number of scalars.

Parameters

scalars (None or list of scalar) – The terms of the sum.

conjugate()

Complex conjugate

atoms()
replace_var(old_variable, new_variable)
get_variables()

Returns the variable of this operator.

is_zero()
expand()
simplify(full=True)
has_variable(variable)

Checks if scalar depends on a given variable.

qualg.scalars.assert_is_scalar(n)

Asserts that something is a scalar