1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA
3// Copyright (C) 2012 - 2016 - Scilab Enterprises
4// Copyright (C) 2018 - Samuel GOUGEON
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12
13function [m,n] = %cblock_size(M, o)
14    n = size(definedfields(M),"*")-1;
15    if ~isdef("o","l") then
16        o = -1    // [m, n]
17    elseif o=="r" | o==1
18        o = 1
19    elseif o=="c" | o==2
20        o = 2
21    elseif o=="*" | o==0
22        o = 0
23    else //
24        o = -1
25    end
26    if n==0 then
27        m = 0
28    else
29        m = size(getfield(2,M),1);
30        if o~=1
31            n = 0
32            for k = 2:size(definedfields(M),"*")
33                n = n + size(getfield(k,M),2);
34            end
35        end
36    end
37    if argn(1)==1 then
38        if o==0
39            m = m*n
40        elseif o==2
41            m = n
42        elseif o==-1
43            m = [m,n]
44        end
45    end
46endfunction
47