# QN

## Description

`ITensors.QN`

— TypeA QN object stores a collection of up to four named values such as ("Sz",1) or ("N",0). These values can include a third integer "m" which makes them obey addition modulo m, for example ("P",1,2) for a value obeying addition mod 2. (The default is regular integer addition).

Adding or subtracting pairs of QN objects performs addition and subtraction element-wise on each of the named values. If a name is missing from the collection, its value is treated as zero.

## Constructors

`ITensors.QN`

— Method`QN(qvs...)`

Construct a QN from a set of up to four named value tuples.

Examples

```
q = QN(("Sz",1))
q = QN(("N",1),("Sz",-1))
q = QN(("P",0,2),("Sz",0)).
```

`ITensors.QN`

— Type`QN(name,val::Int,modulus::Int=1)`

Construct a QN with a single named value by providing the name, value, and optional modulus.

`ITensors.QN`

— Type`QN(val::Int,modulus::Int=1)`

Construct a QN with a single unnamed value (equivalent to the name being the empty string) with optional modulus.

## Properties

`ITensors.val`

— Method`val(q::QN,name)`

Get the value within the QN q corresponding to the string `name`

`ITensors.modulus`

— Method`modulus(q::QN,name)`

Get the modulus within the QN q corresponding to the string `name`

## Related Functions

`Base.zero`

— Method`zero(q::QN)`

Returns a QN object containing the same names as q, but with all values set to zero.