void sqrt_enkf_data_free( void * data ) { sqrt_enkf_data_type * module_data = sqrt_enkf_data_safe_cast( data ); { std_enkf_data_free( module_data->std_data ); free( module_data ); } }
void sqrt_enkf_complete_update( void * arg ) { sqrt_enkf_data_type * sqrt_data = sqrt_enkf_data_safe_cast( arg ); { matrix_free( sqrt_data->randrot ); sqrt_data->randrot = NULL; } }
void sqrt_enkf_initX(void * module_data , matrix_type * X , matrix_type * A , matrix_type * S , matrix_type * R , matrix_type * dObs , matrix_type * E , matrix_type *D ) { sqrt_enkf_data_type * data = sqrt_enkf_data_safe_cast( module_data ); { int ncomp = std_enkf_get_subspace_dimension( data->std_data ); double truncation = std_enkf_get_truncation( data->std_data ); int nrobs = matrix_get_rows( S ); int ens_size = matrix_get_columns( S ); int nrmin = util_int_min( ens_size , nrobs); matrix_type * W = matrix_alloc(nrobs , nrmin); double * eig = util_calloc( nrmin , sizeof * eig ); matrix_subtract_row_mean( S ); /* Shift away the mean */ enkf_linalg_lowrankCinv( S , R , W , eig , truncation , ncomp); enkf_linalg_init_sqrtX( X , S , data->randrot , dObs , W , eig , false); matrix_free( W ); free( eig ); enkf_linalg_checkX( X , false ); } }
bool sqrt_enkf_set_int( void * arg , const char * var_name , int value) { sqrt_enkf_data_type * module_data = sqrt_enkf_data_safe_cast( arg ); { if (std_enkf_set_int( module_data->std_data , var_name , value )) return true; else { /* Could in principle set sqrt specific variables here. */ return false; } } }
void sqrt_enkf_init_update( void * arg , const matrix_type * S , const matrix_type * R , const matrix_type * dObs , const matrix_type * E , const matrix_type * D ) { sqrt_enkf_data_type * sqrt_data = sqrt_enkf_data_safe_cast( arg ); { int ens_size = matrix_get_columns( S ); sqrt_data->randrot = enkf_linalg_alloc_mp_randrot( ens_size , sqrt_data->rng ); } }
long sqrt_enkf_get_options( void * arg , long flag ) { sqrt_enkf_data_type * module_data = sqrt_enkf_data_safe_cast( arg ); { return module_data->options; } }