rssn 0.2.9

A comprehensive scientific computing library for Rust, aiming for feature parity with NumPy and SymPy.
Documentation
//! Handle-based FFI API for physics sim GPE superfluidity functions.

use crate::numerical::matrix::Matrix;
use crate::physics::physics_sim::gpe_superfluidity::GpeParameters;
use crate::physics::physics_sim::gpe_superfluidity::{
    self,
};

/// Runs the GPE ground state finder and returns the result as a Matrix handle (Nx x Ny).
#[unsafe(no_mangle)]
pub extern "C" fn rssn_physics_sim_gpe_run_ground_state_finder(
    nx: usize,
    ny: usize,
    lx: f64,
    ly: f64,
    d_tau: f64,
    time_steps: usize,
    g: f64,
    trap_strength: f64,
) -> *mut Matrix<f64> {
    let params = GpeParameters {
        nx,
        ny,
        lx,
        ly,
        d_tau,
        time_steps,
        g,
        trap_strength,
    };

    match gpe_superfluidity::run_gpe_ground_state_finder(&params) {
        | Ok(res) => {
            let rows = res.nrows();

            let cols = res.ncols();

            Box::into_raw(Box::new(Matrix::new(
                rows,
                cols,
                res.into_raw_vec_and_offset().0,
            )))
        },
        | Err(_) => std::ptr::null_mut(),
    }
}