Hall BCH
log_signatures_pytorch.hall_bch.HallBCH
Truncated BCH on Hall-basis coordinates (supports depth <= 4).
This class implements the Baker-Campbell-Hausdorff formula directly in Hall basis coordinates, allowing incremental log-signature computation without materializing the full tensor-algebra signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Path dimension (size of the alphabet). |
required |
depth
|
int
|
Truncation depth. Must be <= 4 for exact computation. |
required |
device
|
device
|
Device on which to store structure constants and perform computations. |
required |
dtype
|
dtype
|
Data type for computations. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
width |
int
|
Path dimension. |
depth |
int
|
Truncation depth. |
dim |
int
|
Dimension of the log-signature (logsigdim(width, depth)). |
device |
device
|
Device for computations. |
dtype |
dtype
|
Data type for computations. |
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_bch import HallBCH
>>>
>>> bch = HallBCH(width=2, depth=2, device=torch.device("cpu"), dtype=torch.float32)
>>> x = torch.tensor([[1.0, 2.0, 0.0]]) # Hall coordinates (batch=1, dim=3)
>>> y = torch.tensor([[3.0, 4.0, 0.0]]) # Hall coordinates (batch=1, dim=3)
>>> result = bch.bch(x, y)
>>> result.shape
torch.Size([1, 3])
Source code in src/log_signatures_pytorch/hall_bch.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
bch(x, y)
BCH(x, y) truncated to depth <= 4 (caps at 4 if configured higher).
Computes the Baker-Campbell-Hausdorff formula BCH(x, y) = log(exp(x) exp(y)) in Hall coordinates, truncated to the specified depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Tensor of shape |
required |
y
|
Tensor
|
Tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Notes
This method supports depths up to 4. If a higher depth is configured, it caps the computation at depth 4. The caller should use the default signature→log path for higher depths.
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_bch import HallBCH
>>>
>>> bch = HallBCH(width=2, depth=2, device=torch.device("cpu"), dtype=torch.float32)
>>> x = torch.tensor([[1.0, 2.0, 0.0]])
>>> y = torch.tensor([[3.0, 4.0, 0.0]])
>>> result = bch.bch(x, y)
>>> result.shape
torch.Size([1, 3])
Source code in src/log_signatures_pytorch/hall_bch.py
bracket_sparse(x, y)
Sparse scatter-based bracket using nonzero structure constants.
Computes the Lie bracket [x, y] in Hall coordinates using sparse structure constants for efficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Tensor of shape |
required |
y
|
Tensor
|
Tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Notes
This implementation uses sparse structure constants to avoid computing all possible bracket combinations, improving efficiency.
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_bch import HallBCH
>>>
>>> bch = HallBCH(width=2, depth=2, device=torch.device("cpu"), dtype=torch.float32)
>>> x = torch.tensor([[1.0, 2.0, 0.0]])
>>> y = torch.tensor([[3.0, 4.0, 0.0]])
>>> bracket = bch.bracket_sparse(x, y)
>>> bracket.shape
torch.Size([1, 3])
Source code in src/log_signatures_pytorch/hall_bch.py
increment_to_hall(delta)
Embed path increment (batch, width) into Hall coordinates.
Converts a path increment (which lives in degree-1 of the free Lie algebra)
into Hall basis coordinates by placing it in the first width components
and zeroing the rest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delta
|
Tensor
|
Tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_bch import HallBCH
>>>
>>> bch = HallBCH(width=2, depth=2, device=torch.device("cpu"), dtype=torch.float32)
>>> delta = torch.tensor([[1.0, 2.0]]) # (batch=1, width=2)
>>> result = bch.increment_to_hall(delta)
>>> result.shape
torch.Size([1, 3])
>>> result[:, :2] # First two components match delta
tensor([[1., 2.]])
Source code in src/log_signatures_pytorch/hall_bch.py
log_signatures_pytorch.hall_bch.sparse_bch_supports_depth(depth)
Return True if the BCH truncation is implemented for this depth.
Checks whether the sparse Hall-BCH method supports the given depth. Currently, only depths up to 4 are supported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
int
|
Truncation depth to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if depth <= 4, False otherwise. |