/[escript]/trunk/escript/src/DataArrayView.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataArrayView.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/escript/src/Data/DataArrayView.cpp revision 126 by jgs, Fri Jul 22 03:53:08 2005 UTC trunk/escript/src/DataArrayView.cpp revision 856 by gross, Tue Sep 26 01:00:36 2006 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2    
3  /*  /*
4   ******************************************************************************   ************************************************************
5   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
6   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
7   *                                                                            *   *              http://www.access.edu.au                    *
8   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
9   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
10   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
11   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
12   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
13  */  */
14    
15  #include "escript/Data/DataArrayView.h"  #include "DataArrayView.h"
16  #include "escript/Data/DataException.h"  #include "DataException.h"
17    
18  #include <sstream>  #include <sstream>
19  #include <vector>  
 #include <iostream>  
20  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
 #include <boost/python/object.hpp>  
21    
22  using namespace std;  using namespace std;
23  using namespace boost::python;  using namespace boost::python;
# Line 372  getSliceRange(const boost::python::objec Line 368  getSliceRange(const boost::python::objec
368    }    }
369    if (s0 < 0)    if (s0 < 0)
370       throw DataException("Error - slice index out of range.");       throw DataException("Error - slice index out of range.");
371    if (s0 == s1 and s1 >= shape)    if (s0 == s1 && s1 >= shape)
372       throw DataException("Error - slice index out of range.");       throw DataException("Error - slice index out of range.");
373    if (s0 != s1 and  s1>shape)    if (s0 != s1 &&  s1>shape)
374       throw DataException("Error - slice index out of range.");       throw DataException("Error - slice index out of range.");
375    if (s0 > s1)    if (s0 > s1)
376       throw DataException("Error - lower index must less or equal upper index.");       throw DataException("Error - lower index must less or equal upper index.");
# Line 665  DataArrayView::toString(const string& su Line 661  DataArrayView::toString(const string& su
661        break;        break;
662      case 1:      case 1:
663        for (int i=0;i<getShape()[0];i++) {        for (int i=0;i<getShape()[0];i++) {
664      temp << "(" << i << ") " << finalSuffix << (*this)(i);      temp << finalSuffix << "(" << i << ") " << (*this)(i);
665      if (i!=(getShape()[0]-1)) {      if (i!=(getShape()[0]-1)) {
666        temp << endl;        temp << endl;
667      }      }
# Line 674  DataArrayView::toString(const string& su Line 670  DataArrayView::toString(const string& su
670      case 2:      case 2:
671        for (int i=0;i<getShape()[0];i++) {        for (int i=0;i<getShape()[0];i++) {
672      for (int j=0;j<getShape()[1];j++) {      for (int j=0;j<getShape()[1];j++) {
673        temp << "(" << i << "," << j << ") " << finalSuffix << (*this)(i,j);        temp << finalSuffix << "(" << i << "," << j << ") " << (*this)(i,j);
674        if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1))) {        if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1))) {
675          temp << endl;          temp << endl;
676        }        }
# Line 685  DataArrayView::toString(const string& su Line 681  DataArrayView::toString(const string& su
681        for (int i=0;i<getShape()[0];i++) {        for (int i=0;i<getShape()[0];i++) {
682      for (int j=0;j<getShape()[1];j++) {      for (int j=0;j<getShape()[1];j++) {
683        for (int k=0;k<getShape()[2];k++) {        for (int k=0;k<getShape()[2];k++) {
684          temp << "(" << i << "," << j << "," << k << ") " << finalSuffix << (*this)(i,j,k);          temp << finalSuffix << "(" << i << "," << j << "," << k << ") " << (*this)(i,j,k);
685          if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1) && k==(getShape()[2]-1))) {          if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1) && k==(getShape()[2]-1))) {
686            temp << endl;            temp << endl;
687          }          }
# Line 698  DataArrayView::toString(const string& su Line 694  DataArrayView::toString(const string& su
694      for (int j=0;j<getShape()[1];j++) {      for (int j=0;j<getShape()[1];j++) {
695        for (int k=0;k<getShape()[2];k++) {        for (int k=0;k<getShape()[2];k++) {
696          for (int l=0;l<getShape()[3];l++) {          for (int l=0;l<getShape()[3];l++) {
697            temp << "(" << i << "," << j << "," << k << "," << l << ") " << finalSuffix << (*this)(i,j,k,l);            temp << finalSuffix << "(" << i << "," << j << "," << k << "," << l << ") " << (*this)(i,j,k,l);
698            if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1) && k==(getShape()[2]-1) && l==(getShape()[3]-1))) {            if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1) && k==(getShape()[2]-1) && l==(getShape()[3]-1))) {
699              temp << endl;              temp << endl;
700            }            }

Legend:
Removed from v.126  
changed lines
  Added in v.856

  ViewVC Help
Powered by ViewVC 1.1.26