1// ============================================================================= 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3// Copyright (C) 2008 - DIGITEO - Allan CORNET 4// 5// This file is distributed under the same license as the Scilab package. 6// ============================================================================= 7 8// <-- CLI SHELL MODE --> 9 10// <-- Non-regression test for bug 3567 --> 11// 12// <-- Bugzilla URL --> 13// http://bugzilla.scilab.org/show_bug.cgi?id=3567 14// 15// <-- Short Description --> 16// gsort called with a complex array 17warning("off"); 18c = [1 2 3]+%i; 19v = gsort(c); 20ref_v = [ 3. + %i 2. + %i 1. + %i ]; 21if or(v <> ref_v) then pause,end 22 23 24x = [5 8 1; 1 9 4]; 25y = [4 1 8; 1 4 9]; 26c = x+y*%i; 27[v,ind] = gsort(c); 28C = abs(c); 29[v2,ind2] = gsort(C); 30 31ref_ind = [ 4. 3. 1. ; 6. 5. 2. ]; 32ref_v = [ 9. + 4.*%i 8. + %i 5. + 4.*%i ; 4. + 9.*%i 1. + 8.*%i 1. + %i ]; 33if or(ref_ind <> ind) then pause,end 34if or(ref_v <> v) then pause,end 35if or(ref_ind <> ind2) then pause,end 36 37x = [3 1 5 ; 2 9 8]; 38y = [2 4 1 ; 4 1 3]; 39c = x+y*%i; 40C = abs(c); 41 42ref_values = [ 9. + %i 5. + %i 1. + 4.*%i ; 8. + 3.*%i 2. + 4.*%i 3. + 2.*%i ]; 43ref_indices = [ 4. 5. 3. ; 6. 2. 1.]; 44 45[values_1,indices_1] = gsort(c); 46if or(ref_values <> values_1) then pause,end 47if or(ref_indices <> indices_1) then pause,end 48 49ref_indices_C = [ 4. 5. 3. ; 6. 2. 1.]; 50[values_C, indices_C] = gsort(C); 51if or(indices_C <> ref_indices_C) then pause,end 52 53[values_2,indices_2] = gsort(c,'g'); 54if or(values_1 <> values_2) then pause,end 55if or(indices_1 <> indices_2) then pause,end 56 57ref_values_3 = [ 3. + 2.*%i 2. + 4.*%i 8. + 3.*%i ; 1. + 4.*%i 5. + %i 9. + %i ]; 58ref_indices_3 = [ 1. 2. 6. ; 3. 5. 4.]; 59 60[values_3,indices_3] = gsort(c,'g','i'); 61if or(ref_values_3 <> values_3) then pause,end 62if or(ref_indices_3 <> indices_3) then pause,end 63 64[values_4,indices_4] = gsort(c,'g','d'); 65if or(ref_values <> values_4) then pause,end 66if or(ref_indices <> indices_4) then pause,end 67 68[values_gsort,indices_gsort] = gsort(c); 69[values_sort,indices_sort] = gsort(c); 70if or(values_gsort <> values_sort) then pause,end 71if or(indices_gsort <> indices_sort) then pause,end 72 73 74x = [3,1,5]; 75y = [2,4,1]; 76c = x+y*%i; 77ierr = execstr("v = gsort(c,''lr'');","errcatch"); 78if ierr <> 0 then pause,end 79 80ierr = execstr("v = gsort(c,''l'');","errcatch"); 81if ierr <> 999 then pause,end 82 83ierr = execstr("v = gsort(c,''lc'');","errcatch"); 84if ierr <> 0 then pause,end 85 86ierr = execstr("v = gsort(c,''rc'');","errcatch"); 87if ierr <> 999 then pause,end 88 89ierr = execstr("v = gsort(c,''r'');","errcatch"); 90if ierr <> 0 then pause,end 91 92ierr = execstr("v = gsort(c,''c'');","errcatch"); 93if ierr <> 0 then pause,end 94 95