mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-22 20:35:44 +01:00
Introducing read test
This commit is contained in:
parent
000c83f275
commit
3a4726cd78
@ -324,14 +324,18 @@ pub fn write_{group_l}_{element_l}(&self, data: &[&str]) -> Result<(), ExitCode>
|
||||
typ = "(" + ",".join( [ "usize" for _ in range(size) ]) + ", f64)"
|
||||
r += [ ("""
|
||||
pub fn read_{group_l}_{element_l}(&self, offset: usize, buffer_size:usize) -> Result<Vec<{typ}>, ExitCode> {
|
||||
let idx = Vec::<i32>::with_capacity({size}*buffer_size);
|
||||
let val = Vec::<f64>::with_capacity(buffer_size);
|
||||
let mut idx = Vec::<i32>::with_capacity({size}*buffer_size);
|
||||
let mut val = Vec::<f64>::with_capacity(buffer_size);
|
||||
let idx_ptr = idx.as_ptr() as *mut i32;
|
||||
let val_ptr = val.as_ptr() as *mut f64;
|
||||
let offset: i64 = offset.try_into().expect("try_into failed in read_{group}_{element} (offset)");
|
||||
let mut buffer_size_read: i64 = buffer_size.try_into().expect("try_into failed in read_{group}_{element} (buffer_size)");
|
||||
let rc = unsafe { c::trexio_read_safe_{group}_{element}(self.ptr,
|
||||
offset, &mut buffer_size_read, idx_ptr, buffer_size_read, val_ptr, buffer_size_read) };
|
||||
offset, &mut buffer_size_read, idx_ptr, buffer_size_read, val_ptr, buffer_size_read)
|
||||
};
|
||||
let buffer_size_read: usize = buffer_size_read.try_into().expect("try_into failed in read_{group}_{element} (buffer_size)");
|
||||
unsafe { idx.set_len({size}*buffer_size_read) };
|
||||
unsafe { val.set_len(buffer_size_read) };
|
||||
let idx: Vec::<&[i32]> = idx.chunks({size}).collect();
|
||||
|
||||
let mut result = Vec::<{typ}>::with_capacity(buffer_size);
|
||||
|
@ -191,12 +191,11 @@ fn read(file_name: &str, back_end: BackEnd) -> Result<(), trexio::ExitCode> {
|
||||
let spin = trex_file.read_mo_spin()?;
|
||||
assert_eq!(spin, spin_ref);
|
||||
|
||||
/*
|
||||
// Integrals
|
||||
let nmax = 100;
|
||||
let mut ao_2e_int_eri_ref = Vec::<(usize,usize,usize,usize,f64)>::with_capacity(nmax);
|
||||
|
||||
let n_buffers = 5;
|
||||
let n_buffers = 4;
|
||||
let bufsize = nmax/n_buffers;
|
||||
|
||||
for i in 0..100 {
|
||||
@ -206,12 +205,16 @@ fn read(file_name: &str, back_end: BackEnd) -> Result<(), trexio::ExitCode> {
|
||||
}
|
||||
|
||||
let mut offset = 0;
|
||||
for i in 0..n_buffers {
|
||||
trex_file.read_ao_2e_int_eri(offset, &ao_2e_int_eri[offset..offset+bufsize])?;
|
||||
let mut ao_2e_int_eri = Vec::<(usize,usize,usize,usize,f64)>::with_capacity(nmax);
|
||||
for _ in 0..n_buffers {
|
||||
let buffer = trex_file.read_ao_2e_int_eri(offset, bufsize)?;
|
||||
offset += bufsize;
|
||||
ao_2e_int_eri.extend(buffer);
|
||||
}
|
||||
assert_eq!(ao_2e_int_eri_ref, ao_2e_int_eri);
|
||||
|
||||
|
||||
/*
|
||||
// Determinants
|
||||
let det_num = 50;
|
||||
let mut det_list = Vec::with_capacity(det_num);
|
||||
|
Loading…
Reference in New Issue
Block a user