53 Array::_duplicate(
const Array &a)
72 Array::update_length(
int)
75 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
76 length *= (*i).c_size > 0 ? (*i).c_size : 1;
133 DBG(cerr <<
"Entering ~Array (" <<
this <<
")" << endl);
134 DBG(cerr <<
"Exiting ~Array" << endl);
140 return new Array(*
this);
149 dynamic_cast<Vector &
>(*this) = rhs;
245 _shape.insert(_shape.begin(), d);
261 for (
Dim_iter i = _shape.begin(); i != _shape.end(); i++) {
263 (*i).stop = (*i).size - 1;
265 (*i).c_size = (*i).size;
289 static const char *array_sss = \
290 "Invalid constraint parameters: At least one of the start, stride or stop \n\
291 specified do not match the array variable.";
321 if (start >= d.
size || stop >= d.
size || stride > d.
size || stride <= 0)
324 if (((stop - start) / stride + 1) > d.
size)
331 d.
c_size = (stop - start) / stride + 1;
333 DBG(cerr <<
"add_constraint: c_size = " << d.
c_size << endl);
342 return _shape.begin() ;
349 return _shape.end() ;
364 unsigned int dim = 0;
365 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
394 if (!_shape.empty()) {
425 return (!_shape.empty()) ? (*i).start : 0;
449 return (!_shape.empty()) ? (*i).stop : 0;
474 return (!_shape.empty()) ? (*i).stride : 0;
497 "*This* array has no dimensions.");
521 bool constraint_info,
bool constrained)
523 if (constrained && !
send_p())
527 var()->
print_decl(out, space,
false, constraint_info, constrained);
529 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
531 if ((*i).name !=
"") {
532 fprintf(out,
"%s = ",
id2www((*i).name).c_str()) ;
535 fprintf(out,
"%d]", (*i).c_size) ;
538 fprintf(out,
"%d]", (*i).size) ;
543 fprintf(out,
";\n") ;
567 bool constraint_info,
bool constrained)
569 if (constrained && !
send_p())
573 var()->
print_decl(out, space,
false, constraint_info, constrained);
575 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
577 if ((*i).name !=
"") {
578 out <<
id2www((*i).name) <<
" = " ;
581 out << (*i).c_size <<
"]" ;
584 out << (*i).size <<
"]" ;
617 class PrintArrayDim :
public unary_function<Array::dimension&, void>
623 PrintArrayDim(FILE *o,
string s,
bool c)
624 : d_out(o), d_space(s), d_constrained(c)
627 void operator()(Array::dimension &d)
629 int size = d_constrained ? d.c_size : d.size;
631 fprintf(d_out,
"%s<dimension size=\"%d\"/>\n", d_space.c_str(),
634 fprintf(d_out,
"%s<dimension name=\"%s\" size=\"%d\"/>\n",
635 d_space.c_str(),
id2xml(d.name).c_str(), size);
642 if (constrained && !
send_p())
645 fprintf(out,
"%s<%s", space.c_str(), tag.c_str());
647 fprintf(out,
" name=\"%s\"",
id2xml(
name()).c_str());
648 fprintf(out ,
">\n");
653 string tmp_name = btp->
name();
655 btp->
print_xml(out, space +
" ", constrained);
659 PrintArrayDim(out, space +
" ", constrained));
661 fprintf(out,
"%s</%s>\n", space.c_str(), tag.c_str());
665 class PrintArrayDimStrm :
public unary_function<Array::dimension&, void>
671 PrintArrayDimStrm(ostream &o,
string s,
bool c)
672 : d_out(o), d_space(s), d_constrained(c)
675 void operator()(Array::dimension &d)
677 int size = d_constrained ? d.c_size : d.size;
679 d_out << d_space <<
"<dimension size=\"" << size <<
"\"/>\n" ;
681 d_out << d_space <<
"<dimension name=\"" <<
id2xml(d.name)
682 <<
"\" size=\"" << size <<
"\"/>\n" ;
689 if (constrained && !
send_p())
692 out << space <<
"<" << tag ;
700 string tmp_name = btp->
name();
702 btp->
print_xml(out, space +
" ", constrained);
706 PrintArrayDimStrm(out, space +
" ", constrained));
708 out << space <<
"</" << tag <<
">\n" ;
725 unsigned int shape[])
729 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
746 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
747 index =
print_array(out, index, dims - 1, shape + 1);
750 index =
print_array(out, index, dims - 1, shape + 1);
771 unsigned int shape[])
775 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
792 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
793 index =
print_array(out, index, dims - 1, shape + 1);
796 index =
print_array(out, index, dims - 1, shape + 1);
815 fprintf(out,
" = ") ;
818 unsigned int *shape =
new unsigned int[_shape.size()];
819 unsigned int index = 0;
820 for (
Dim_iter i = _shape.begin(); i != _shape.end() && index < _shape.size(); i++)
825 delete [] shape; shape = 0;
828 fprintf(out,
";\n") ;
847 unsigned int *shape =
new unsigned int[
dimensions(
true)];
848 unsigned int index = 0;
854 delete [] shape; shape = 0;
876 msg =
"An array variable must have dimensions";
893 << (
void *)
this <<
")" << endl ;
897 DapIndent::Indent() ;
900 unsigned int dim_num = 0 ;
901 for (; i != ie; i++) {
904 DapIndent::Indent() ;