void
check_block_size(length_type g_size, length_type l_size, ViewT const& view)
{
  test_assert(g_size == view.size(0));
  test_assert(g_size == view.block().size(1, 0));

  test_assert(l_size == view.local().size(0));
  test_assert(l_size == view.local().block().size(1, 0));

  test_assert(g_size == view.size());
  test_assert(g_size == view.block().size());

  test_assert(l_size == view.local().size());
  test_assert(l_size == view.local().block().size());
}
  void write(std::ostream& os,ViewT v)
  {
    vsip::dimension_type const View_dim = ViewT::dim;
    vsip::Index<View_dim> my_index;
    vsip::impl::Length<View_dim> v_extent = extent(v);
    typename ViewT::value_type data;

    // get num_points
    vsip::length_type num_points = v.size();

    // write all the points
    for(vsip::index_type i=0;i<num_points;i++) {
      data = get(v,my_index);
      os.write(reinterpret_cast<char*>(&data),sizeof(data));

      // increment index
      my_index = vsip::impl::next<typename vsip::impl::Col_major<View_dim>::type>
        (v_extent,my_index);
    }

    // Matlab data blocks must be padded to a multiple of 8 bytes.
    if (sizeof(data) < 8)
    {
      for(vsip::index_type i = 0; i < (num_points % 8/sizeof(data)); i++) {
        os.write(reinterpret_cast<char*>(&data),sizeof(data));
      }
    }
  }
  void read(std::istream& is,ViewT v,bool swap_bytes)
  {
    vsip::dimension_type const View_dim = ViewT::dim;
    vsip::Index<View_dim> my_index;
    vsip::impl::Length<View_dim> v_extent = extent(v);
    T1 data;
    typedef typename ViewT::value_type scalar_type;

    // get num_points
    vsip::length_type num_points = v.size();

    // read all the points
    for(vsip::index_type i=0;i<num_points;i++) {
      is.read(reinterpret_cast<char*>(&data),sizeof(data));
      swap(&data,swap_bytes);
      put(v,my_index,scalar_type(data));

      // increment index
      my_index = vsip::impl::next<typename vsip::impl::Col_major<View_dim>::type>
        (v_extent,my_index);
    }
    
    // Matlab data blocks must be padded to a multiple of 8 bytes.
    if (sizeof(data) < 8)
    {
      for(vsip::index_type i = 0; i < (num_points % 8/sizeof(data)); i++) {
        is.read(reinterpret_cast<char*>(&data),sizeof(data));
      }
    }
  }
Exemple #4
0
typename ViewT::value_type
get(ViewT view, stride_type r, stride_type c, 
    stride_type rr, stride_type cc)
{
  if (r + rr >= 0 && r + rr < (stride_type)view.size(0) &&
      c + cc >= 0 && c + cc < (stride_type)view.size(1))
    return view.get(r + rr, c + cc);
  else
    return typename ViewT::value_type(0);
}