let mapi f a =
  { data = Array.mapi f (Array.sub a.data 0 a.length);
    length = a.length ;
    step = a.step ;
  }