1 function [resu, rcond] = inv(df);
3 %# function [x, rcond] = inv(df)
4 %# Overloaded function computing the inverse of a dataframe. To
5 %# succeed, the dataframe must be convertible to an square array. Row
6 %# and column meta-information are exchanged.
8 %% Copyright (C) 2009-2012 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
10 %% This file is part of Octave.
12 %% Octave is free software; you can redistribute it and/or
13 %% modify it under the terms of the GNU General Public
14 %% License as published by the Free Software Foundation;
15 %% either version 2, or (at your option) any later version.
17 %% Octave is distributed in the hope that it will be useful,
18 %% but WITHOUT ANY WARRANTY; without even the implied
19 %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 %% PURPOSE. See the GNU General Public License for more
23 %% You should have received a copy of the GNU General Public
24 %% License along with Octave; see the file COPYING. If not,
25 %% write to the Free Software Foundation, 51 Franklin Street -
26 %% Fifth Floor, Boston, MA 02110-1301, USA.
29 %# $Id: inv.m 9585 2012-02-05 15:32:46Z cdemills $
32 if (length(df._cnt) > 2 || (df._cnt(1) != df._cnt(2))),
33 error("Dataframe is not square");
36 %# quick and dirty conversion
37 [dummy, rcond] = inv(horzcat(df._data{:}));
39 resu = df_allmeta(df);
41 [resu._name{2}, resu._name{1}] = deal(resu._name{1}, resu._name{2});
42 [resu._over{2}, resu._over{1}] = deal(resu._over{1}, resu._over{2});
43 if (isempty(resu._name{2})),
44 resu._name{2} = cellstr(repmat('_', resu._cnt(2), 1));
45 resu._over{2} = ones(1, resu._cnt(2));
47 for indi = resu._cnt(1):-1:1,
48 resu._data{indi} = dummy(:, indi);
50 resu._type(:) = class(dummy);