← カタログに戻る

pysparseir

SpM-lab / pysparseir

スパース中間表現(IR)ライブラリ libsparseir の Python バインディング

強相関電子系・有効模型PythonMIT
1更新: 2025-09-07

概要

(説明は未登録です)

典型的な利用シーン

Quick Start

このソフトウェアには Quickstart / チュートリアルが用意されています。

README

pysparseir

Ask DeepWiki

Python bindings for the libsparseir library, providing efficient sparse intermediate representation for many-body physics calculations.

Overview

pysparseir is a Python wrapper for the libsparseir C++ library, which implements the sparse intermediate representation (IR) method for Green's functions in many-body physics. The library provides efficient tools for working with fermionic and bosonic systems.

Requirements

  • Python >= 3.12
  • CMake (for building the C++ library)
  • C++11 compatible compiler
  • numpy

Installation

1. Clone the Repository
git clone --recursive https://github.com/SpM-lab/pysparseir.git
cd pysparseir

Important: Use --recursive to automatically initialize git submodules.

2. Initialize Submodules (if not cloned recursively)

If you forgot to use --recursive when cloning:

git submodule init
git submodule update
3. Install Dependencies and Build
uv sync

This will:

  • Install Python dependencies (numpy)
  • Build the C++ libsparseir library using CMake
  • Install the Python package in development mode

Usage

Basic Example
import pylibsparseir

# Create a logistic kernel
kernel = pylibsparseir.LogisticKernel(1.0)

# Create a regularized bosonic kernel
bose_kernel = pylibsparseir.reg_bose_kernel_new(1.0)

# Get kernel domain
xmin, xmax, ymin, ymax = pylibsparseir.kernel_domain(kernel)
print(f"Kernel domain: x=[{xmin}, {xmax}], y=[{ymin}, {ymax}]")

# Create SVE result
sve = pylibsparseir.sve_result_new(kernel, 1e-12)
size = pylibsparseir.sve_result_get_size(sve)
print(f"SVE result size: {size}")

# Get singular values
svals = pylibsparseir.sve_result_get_svals(sve)
print(f"First few singular values: {svals[:5]}")
Alternative Import

You can also import with an alias:

import pylibsparseir as pysparseir

kernel = pysparseir.LogisticKernel(1.0)

Development

Project Structure
pysparseir/
├── libsparseir/          # C++ library (git submodule)
├── src/
│   └── pylibsparseir/    # Python package
│       ├── __init__.py
│       ├── core.py       # Main wrapper functions
│       ├── constants.py  # Constants
│       └── ctypes_wrapper.py  # ctypes type definitions
├── setup.py              # Build configuration
├── pyproject.toml        # Project metadata
└── README.md

Troubleshooting

Common Issues
  1. CMake Error: CMakeLists.txt not found

    git submodule init
    git submodule update
    
  2. ModuleNotFoundError: No module named 'pylibsparseir'

    uv sync --reinstall
    
  3. Symbol not found errors

    • Ensure the C++ library built successfully
    • Check that the shared library files (*.dylib on macOS, *.so on Linux) exist in src/pylibsparseir/
  4. Import errors

    • Make sure numpy is installed: uv add numpy
    • Verify Python >= 3.12 is being used
Checking Installation

To verify the installation works:

uv run python -c "import pylibsparseir; print('✓ Installation successful!')"

出典: https://github.com/SpM-lab/pysparseir の README

充実度

低調最終更新: 2025-09-07 ()

充実度 = ドキュメント(docs)・サンプル(examples)・テスト(tests)の3項目の整備状況を★3で表示します(1星=1項目/下のチェックリストが内訳)。リポジトリ情報を取得していない(手動で登録した)ソフトウェアは自動評価の対象外で、充実度の絞り込み(1 以上)では表示されません。

情報

主要言語
Python
言語
Python
ライセンス
MIT
提供元
github

問い合わせ・貢献