~ubuntu-branches/ubuntu/trusty/r-cran-rcpparmadillo/trusty

« back to all changes in this revision

Viewing changes to inst/include/armadillo_bits/op_shuffle_meat.hpp

  • Committer: Package Import Robot
  • Author(s): Dirk Eddelbuettel
  • Date: 2013-12-09 18:13:21 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20131209181321-cc9ycvs53xfiz5ow
Tags: 0.3.930.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (C) 2009-2012 Conrad Sanderson
2
 
// Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
 
1
// Copyright (C) 2009-2013 Conrad Sanderson
 
2
// Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
3
3
// Copyright (C) 2009-2010 Dimitrios Bouzas
4
4
// 
5
5
// This Source Code Form is subject to the terms of the Mozilla Public
28
28
  if(X.is_empty()) { out.copy_size(X); return; }
29
29
  
30
30
  const uword dim = in.aux_uword_a;
31
 
  const uword N   = (dim == 0) ? X.n_rows : X.n_cols;
 
31
  
 
32
  arma_debug_check( (dim > 1), "shuffle(): dim must be 0 or 1" );
 
33
  
 
34
  const uword N = (dim == 0) ? X.n_rows : X.n_cols;
 
35
  
32
36
  
33
37
  // see "fn_sort_index.hpp" for the definition of "arma_sort_index_packet"
34
38
  // and the associated comparison functor
36
40
  
37
41
  for(uword i=0; i<N; ++i)
38
42
    {
39
 
    packet_vec[i].val   = std::rand();
 
43
    packet_vec[i].val   = int(arma_rng::randi<int>());
40
44
    packet_vec[i].index = i;
41
45
    }
42
46
  
43
47
  arma_sort_index_helper_ascend comparator;
44
 
 
 
48
  
45
49
  std::sort( packet_vec.begin(), packet_vec.end(), comparator );
46
50
  
47
51
  const bool is_alias = (&out == &X);