comparison liboctave/array/Array.cc @ 21120:499b851fbfae

Replace pattern if/err_XXX/else/code with if/err_XXX/ code. * schur.cc, ov-complex.h, ov-cx-mat.cc, ov-cx-sparse.cc, ov-float.h, ov-flt-complex.h, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.h, ov-str-mat.cc, ops.h, pt-idx.cc, Array.cc, CColVector.cc, CMatrix.cc, CRowVector.cc, MSparse.cc, PermMatrix.cc, Sparse.cc, dColVector.cc, dMatrix.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCMatrix.cc, fCRowVector.cc, fColVector.cc, fMatrix.cc, fRowVector.cc: Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
author Rik <rik@octave.org>
date Wed, 20 Jan 2016 16:58:59 -0800
parents 3ac9f47fb04b
children 54527108599a
comparison
equal deleted inserted replaced
21119:90cd0f9442d5 21120:499b851fbfae
931 else 931 else
932 invalid = true; 932 invalid = true;
933 933
934 if (invalid) 934 if (invalid)
935 err_invalid_resize (); 935 err_invalid_resize ();
936 else 936
937 { 937 octave_idx_type nx = numel ();
938 octave_idx_type nx = numel (); 938 if (n == nx - 1 && n > 0)
939 if (n == nx - 1 && n > 0) 939 {
940 { 940 // Stack "pop" operation.
941 // Stack "pop" operation. 941 if (rep->count == 1)
942 if (rep->count == 1) 942 slice_data[slice_len-1] = T ();
943 slice_data[slice_len-1] = T (); 943 slice_len--;
944 slice_len--; 944 dimensions = dv;
945 }
946 else if (n == nx + 1 && nx > 0)
947 {
948 // Stack "push" operation.
949 if (rep->count == 1
950 && slice_data + slice_len < rep->data + rep->len)
951 {
952 slice_data[slice_len++] = rfv;
945 dimensions = dv; 953 dimensions = dv;
946 } 954 }
947 else if (n == nx + 1 && nx > 0) 955 else
948 { 956 {
949 // Stack "push" operation. 957 static const octave_idx_type max_stack_chunk = 1024;
950 if (rep->count == 1 958 octave_idx_type nn = n + std::min (nx, max_stack_chunk);
951 && slice_data + slice_len < rep->data + rep->len) 959 Array<T> tmp (Array<T> (dim_vector (nn, 1)), dv, 0, n);
952 {
953 slice_data[slice_len++] = rfv;
954 dimensions = dv;
955 }
956 else
957 {
958 static const octave_idx_type max_stack_chunk = 1024;
959 octave_idx_type nn = n + std::min (nx, max_stack_chunk);
960 Array<T> tmp (Array<T> (dim_vector (nn, 1)), dv, 0, n);
961 T *dest = tmp.fortran_vec ();
962
963 std::copy (data (), data () + nx, dest);
964 dest[nx] = rfv;
965
966 *this = tmp;
967 }
968 }
969 else if (n != nx)
970 {
971 Array<T> tmp = Array<T> (dv);
972 T *dest = tmp.fortran_vec (); 960 T *dest = tmp.fortran_vec ();
973 961
974 octave_idx_type n0 = std::min (n, nx); 962 std::copy (data (), data () + nx, dest);
975 octave_idx_type n1 = n - n0; 963 dest[nx] = rfv;
976 std::copy (data (), data () + n0, dest);
977 std::fill_n (dest + n0, n1, rfv);
978 964
979 *this = tmp; 965 *this = tmp;
980 } 966 }
967 }
968 else if (n != nx)
969 {
970 Array<T> tmp = Array<T> (dv);
971 T *dest = tmp.fortran_vec ();
972
973 octave_idx_type n0 = std::min (n, nx);
974 octave_idx_type n1 = n - n0;
975 std::copy (data (), data () + n0, dest);
976 std::fill_n (dest + n0, n1, rfv);
977
978 *this = tmp;
981 } 979 }
982 } 980 }
983 981
984 template <class T> 982 template <class T>
985 void 983 void