Commit 08fc9d43 authored by Ole Koenig's avatar Ole Koenig

merge_struct_arrays: add keep_null qualifier

* Helpful in combination with get_params if some parameters are tied
  and others are not
* Without keep_null qualifier merge_struct_arrays(get_params())
  filters the NULL entries in the tied field, (i.e., all untied
  parameters are filtered out), which causes problems if one wants to
  filter the struct later.
parent aa9cab0b
......@@ -9,7 +9,8 @@ define merge_struct_arrays()
% All elements of s have to be structures with the same fields.
% The return value merged_s is another structure of this kind, and
% merged_s.field = [s[0].field, s[1].field, ..., s[-1].field];
% holds for every field. (If s[i].field is NULL, it is skipped.)
% holds for every field. (If s[i].field is NULL, it is skipped
% unless "keep_null" qualifier is set.)
%\qualifiers{
%\qualifier{remove_excess_fields}{: remove fields not present in all
% structures.}
......@@ -17,6 +18,7 @@ define merge_struct_arrays()
% dimensions of the original fields, using the sum of dimensiom 'dim'
% to account for the increased array. Care has to be taken that the
% other dimension need to have the same length in all structures. }
%\qualifier{keep_null}{: keep fields which contain NULL.}
%}
%\seealso{append_struct_arrays, get_intersection, reshape}
%!%-
......@@ -50,13 +52,13 @@ define merge_struct_arrays()
{
variable findim = 0 ;
variable a = get_struct_field(s[0], field);
if(a!=NULL){ a = [a];
if(a!=NULL or qualifier_exists("keep_null")){ a = [a];
(dim,,)= array_info(a) ;
findim += dim[resh] ;
}
_for i (1, length(s)-1, 1)
{ variable a_ = get_struct_field(s[i], field);
if(a_!=NULL) { a = [a, a_];
if(a_!=NULL or qualifier_exists("keep_null")) { a = [a, a_];
(dim,,)= array_info(a_) ;
findim += dim[resh] ;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment