| Crates.io | scirs2-core |
| lib.rs | scirs2-core |
| version | 0.1.2 |
| created_at | 2025-04-12 11:12:15.997243+00 |
| updated_at | 2026-01-16 08:21:36.394075+00 |
| description | Core utilities and common functionality for SciRS2 (scirs2-core) |
| homepage | |
| repository | https://github.com/cool-japan/scirs |
| max_upload_size | |
| id | 1630819 |
| size | 10,624,523 |
Production-Ready Scientific Computing Core for Rust
π― SciRS2 Core v0.1.0 (Released December 29, 2025) - Production-ready foundation providing comprehensive abstractions for the entire SciRS2 ecosystem with ultra-performance SIMD, multi-backend GPU support, and advanced parallel processing.
[dependencies]
scirs2-core = { version = "0.1.2", features = ["validation", "simd", "parallel"] }
use scirs2_core::prelude::*;
// Create and validate data
let data = array![[1.0, 2.0], [3.0, 4.0]];
check_finite(&data, "input_matrix")?;
// Perform operations with automatic optimization
let normalized = normalize_matrix(&data)?;
let result = parallel_matrix_multiply(&normalized, &data.t())?;
# Ok::<(), Box<dyn std::error::Error>>(())
scirs2_core::prelude)SciRS2 Core v0.1.0 provides the SciRS2 Ecosystem Policy that establishes architectural consistency:
scirs2-core uses external dependencies directly// β PROHIBITED in non-core crates
use rand::*;
use ndarray::Array2;
use num_complex::Complex;
// β
REQUIRED in non-core crates
use scirs2_core::random::*; // Instead of rand::*
use scirs2_core::array::*; // Instead of ndarray::*
use scirs2_core::complex::*; // Instead of num_complex::*
See SCIRS2_POLICY.md for complete details.
// Error handling
use scirs2_core::{CoreError, CoreResult, value_err_loc};
// Mathematical constants
use scirs2_core::constants::{PI, E, SPEED_OF_LIGHT};
// Validation utilities
use scirs2_core::validation::{check_positive, check_shape, check_finite};
validation feature)use scirs2_core::validation::data::{Validator, ValidationSchema, Constraint};
let schema = ValidationSchema::new()
.require_field("temperature", DataType::Float64)
.add_constraint("temperature", Constraint::Range { min: -273.15, max: 1000.0 });
let validator = Validator::new(Default::default())?;
let result = validator.validate(&data, &schema)?;
gpu feature)use scirs2_core::gpu::{GpuContext, select_optimal_backend};
let backend = select_optimal_backend()?;
let ctx = GpuContext::new(backend)?;
let mut buffer = ctx.create_buffer::<f32>(1_000_000);
buffer.copy_from_host(&host_data);
memory_management feature)use scirs2_core::memory::{ChunkProcessor2D, BufferPool, track_allocation};
// Process large arrays in chunks
let processor = ChunkProcessor2D::new(&large_array, (1000, 1000));
processor.process_chunks(|chunk, coords| {
println!("Processing chunk at {:?}", coords);
})?;
// Memory pooling
let mut pool = BufferPool::<f64>::new();
let mut buffer = pool.acquire_vec(1000);
simd feature)use scirs2_core::simd::{simd_add, simd_multiply, simd_fused_multiply_add};
let a = vec![1.0f32; 1000];
let b = vec![2.0f32; 1000];
let c = vec![3.0f32; 1000];
let result = simd_fused_multiply_add(&a, &b, &c)?; // (a * b) + c
parallel feature)use scirs2_core::parallel::{parallel_map, parallel_reduce, set_num_threads};
set_num_threads(8);
let results = parallel_map(&data, |&x| expensive_computation(x))?;
let sum = parallel_reduce(&data, 0.0, |acc, &x| acc + x)?;
use scirs2_core::prelude::*;
// Load and validate
let measurements = load_csv_data("experiment.csv")?;
check_finite(&measurements, "data")?;
// Statistical analysis
let correlation_matrix = calculate_correlation(&measurements)?;
let outliers = detect_outliers(&measurements, 3.0)?;
use scirs2_core::{gpu::*, validation::*, array_protocol::*};
// Validate training data
validate_training_data(&features, &labels, &schema)?;
// GPU-accelerated training
let gpu_config = GPUConfig::high_performance();
let gpu_features = GPUNdarray::new(features, gpu_config);
use scirs2_core::memory::*;
// Memory-efficient processing
let memory_mapped = MemoryMappedArray::<f64>::open("large_dataset.bin")?;
let processor = ChunkProcessor::new(&memory_mapped, ChunkSize::Adaptive);
# Minimal scientific computing
scirs2-core = { version = "0.1.2", features = ["validation"] }
# High-performance CPU computing
scirs2-core = { version = "0.1.2", features = ["validation", "simd", "parallel"] }
# GPU-accelerated computing
scirs2-core = { version = "0.1.2", features = ["validation", "gpu", "cuda"] }
# Full-featured development
scirs2-core = { version = "0.1.2", features = ["all"] }
| Feature | Description | Use Case |
|---|---|---|
validation |
Data validation and integrity | All applications |
simd |
CPU vector acceleration | CPU-intensive computations |
parallel |
Multi-core processing | Large datasets |
gpu |
GPU acceleration | GPU computing |
cuda |
NVIDIA CUDA backend | NVIDIA GPUs |
memory_management |
Advanced memory utilities | Large-scale apps |
array_protocol |
Extensible array system | Framework development |
logging |
Structured logging | Production deployment |
profiling |
Performance monitoring | Optimization |
all |
All stable features | Development |
Ultra-Optimized SIMD Performance (targeting 80-90% memory bandwidth):
Operation | NumPy/SciPy | SciRS2 Core | Speedup
--------------------------------|-------------|-------------|--------
Element-wise Operations (1M) | 10.05ms | 0.71ms | 14.17x
Signal Convolution | 52.5ms | 2.1ms | 25.0x
Statistical Moments | 45.3ms | 1.8ms | 25.2x
Monte Carlo Bootstrap | 267.0ms | 8.9ms | 30.0x
QMC Sequence Generation | 48.7ms | 3.2ms | 15.2x
FFT Fractional Transform | 112.3ms | 4.5ms | 24.9x
GPU Matrix Multiply | N/A | 3ms | 42x vs CPU
use scirs2_core::observability::{Logger, MetricsCollector};
// Structured logging
let logger = Logger::new("pipeline").with_field("exp_id", "001");
logger.info("Processing", &[("batch_size", "1000")]);
// Metrics collection
let metrics = MetricsCollector::new();
metrics.record_histogram("processing_time_ms", duration.as_millis());
We welcome contributions! See Contributing Guide.
git clone https://github.com/cool-japan/scirs.git
cd scirs/scirs2-core
cargo test --all-features
cargo clippy without warningsDual-licensed under:
SciRS2 Core is part of the SciRS2 ecosystem:
SciRS2 Core v0.1.0 is production-ready for:
Note: Migration to scirs2-core abstractions is ongoing across the ecosystem. Core functionality is stable and ready for production use.
Built with β€οΈ for the scientific computing community
Version: 0.1.0 | Released: December 29, 2025 | Next: 0.1.0