1//<-- CLI SHELL MODE -->
2// =============================================================================
3// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
5//
6//  This file is distributed under the same license as the Scilab package.
7// =============================================================================
8// <-- Non-regression test for bug 11996 -->
9//
10// <-- Bugzilla URL -->
11// http://bugzilla.scilab.org/show_bug.cgi?id=11996
12//
13// <-- Short Description -->
14// Extend eye() to hypermatrix
15ref222(:,:,1) = [1,0;0,0];
16ref222(:,:,2) = [0,0;0,1];
17assert_checkequal(eye(rand(2,2,2)), ref222);
18ref4445(:,:,1,1) = [1,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0];
19ref4445(:,:,2,1) = zeros(4,4);
20ref4445(:,:,3,1) = zeros(4,4);
21ref4445(:,:,4,1) = zeros(4,4);
22ref4445(:,:,1,2) = zeros(4,4);
23ref4445(:,:,2,2) = [0,0,0,0;0,1,0,0;0,0,0,0;0,0,0,0];
24ref4445(:,:,3,2) = zeros(4,4);
25ref4445(:,:,4,2) = zeros(4,4);
26ref4445(:,:,1,3) = zeros(4,4);
27ref4445(:,:,2,3) = zeros(4,4);
28ref4445(:,:,3,3) = [0,0,0,0;0,0,0,0;0,0,1,0;0,0,0,0];
29ref4445(:,:,4,3) = zeros(4,4);
30ref4445(:,:,1,4) = zeros(4,4);
31ref4445(:,:,2,4) = zeros(4,4);
32ref4445(:,:,3,4) = zeros(4,4);
33ref4445(:,:,4,4) = [0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,1];
34ref4445(:,:,1,5) = zeros(4,4);
35ref4445(:,:,2,5) = zeros(4,4);
36ref4445(:,:,3,5) = zeros(4,4);
37ref4445(:,:,4,5) = zeros(4,4);
38assert_checkequal(eye(zeros(4,4,4,5)), ref4445);
39M = matrix(1:24, [2 3 2 2]);
40ref2322(:,:,1,1) = [1,0,0;0,0,0];
41ref2322(:,:,2,1) = zeros(2,3);
42ref2322(:,:,1,2) = zeros(2,3);
43ref2322(:,:,2,2) = [0,0,0;0,1,0];
44assert_checkequal(eye(M), ref2322);
45ref5(:,:,1) = [1,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0];
46ref5(:,:,2) = [0,0,0,0;0,1,0,0;0,0,0,0;0,0,0,0];
47ref5(:,:,3) = [0,0,0,0;0,0,0,0;0,0,1,0;0,0,0,0];
48ref5(:,:,4) = [0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,1];
49assert_checkequal(eye(4,4,4), ref5);
50