Examples¶
This section provides comprehensive, executable examples demonstrating Nicole's capabilities for symmetry-aware tensor computations. Each example includes live code execution with real outputs, allowing you to see exactly what Nicole produces.
The examples are organized by complexity and topic:
- Basic: Learn tensor creation, arithmetic, and block access
- Symmetries: Work with U(1), Z(2), and product groups
- Operations: Master contractions, decompositions, and manipulations
- Advanced: Build operators and optimize performance
All code examples use markdown-exec to show both the source code and its actual output, making it easy to understand what each operation does and verify the results.
Getting Started¶
New to Nicole? Start here:
- First Tensor: Create your first symmetry-aware tensor
- Arithmetic Operations: Add, subtract, and scale tensors
- Indexing and Blocks: Access and manipulate tensor blocks
Symmetries¶
Learn to work with different symmetry groups:
- U1 Examples: Particle number conservation
- Z2 Examples: Parity and binary symmetries
- SU(2) Examples: Full spin-rotation symmetry
- Product Groups: Multiple simultaneous symmetries
Operations¶
Master tensor operations:
- Contraction: Contract, trace, and multiply tensors
- Decomposition: SVD and tensor decomposition
- Manipulation: Permute, transpose, conjugate
- Serialization: Save and load tensors to disk
Advanced¶
For experienced users:
- Build Operators: Build physical operators with symmetries
- Load Space: Use
load_spacefor quantum systems - Performance Tips: Optimize your code
- Autograd: Gradient tracking with symmetry-aware tensors
- GPU Acceleration: Run computations on GPU
Example Format¶
Each example page includes:
- Complete runnable code
- Step-by-step explanations
- Expected output
- Links to API reference
Running Examples¶
All examples assume Nicole is installed:
Then copy-paste code directly into Python or Jupyter notebooks.
Contributing Examples¶
Have an interesting use case? Contributions welcome! See the GitHub repository to submit examples.
See Also¶
- API Reference: Complete function documentation
- Core Concepts: Understanding symmetry-aware tensors
- Quick Examples: Hands-on introduction