[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Class of User Types [Was: Moving code from octave-forge to octave [W
From: |
Paul Kienzle |
Subject: |
Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]] |
Date: |
Fri, 25 Feb 2005 08:57:21 -0500 |
On Feb 25, 2005, at 8:24 AM, David Bateman wrote:
Paul Kienzle wrote:
Another alternative is to delay recording the primitive polynomial
type
until something is actually assigned to the matrix, and from then on
check
that it is consistent. Would that work for you?
Err, I have to admit that you can do
gf(floor(8*rand(4,4)),8) + ones(4,4)
As the galois/matrix operations are already taken into account with
the matrix promoted the a galois field. However
a = zeros(4,4); a(:,1) = gf(floor(8*rand(4,1)),8)
won't promote a, but leave it as a matrix, and so the implementation
of triu won't work. I suppose an alternative for the galois fields is
to modify the assign function to promote the matrix to a galois field
as well... This might also work for the fixed point operators.
I was thinking:
z = zeros(4,4,class(X));
for i=1:columns(X), z(1:i,:) = X(1:i,:); end
so z would already be known to be a galois type but with an
indeterminate
field.
Or maybe something more generic, such as array(exemplar,dims) so that
dispatch will work. Also, this makes more sense for some types such
as 'cell' for which I was assuming the zeros function would create a
set of empty cells.
Then triu would be:
z = array(X,size(X));
for i=1:columns(X), z(1:i,:) = X(1:i,:); end
Otherwise, zeros(dims,'auto',exemplar) does do what we want assuming
the class registers a zeros constructor.
I don't see that we need an explicit zero constructor,
octave_value retval = args(0);
retval = retval.resize(dim_vector(0,0)).resize(args(0).dims());
does exactly the right.
Okay, that means we can implement it without touching octave. I'm
not too keen on the name 'array' though. I suppose we could get
away with just exposing resize and implement triu as:
z = resize(resize(X,[0,0]),size(X));
for i=1:columns(X), z(1:i,:) = X(1:i,:); end
Not quite as pretty but it'll do. Resize can also be used to implement
postpad.
- Paul
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], (continued)
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], Paul Kienzle, 2005/02/23
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], David Bateman, 2005/02/24
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], Paul Kienzle, 2005/02/24
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], David Bateman, 2005/02/24
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], Paul Kienzle, 2005/02/24
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], David Bateman, 2005/02/24
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], Paul Kienzle, 2005/02/24
- Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], David Bateman, 2005/02/25
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], Paul Kienzle, 2005/02/25
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], David Bateman, 2005/02/25
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]],
Paul Kienzle <=
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], John W. Eaton, 2005/02/25
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], David Bateman, 2005/02/25
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], John W. Eaton, 2005/02/25
- Re: Class of User Types [Was: Moving code from octave-forge to octave [Was: polyderiv problem?]], David Bateman, 2005/02/25
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], Przemek Klosowski, 2005/02/10
- Re: Moving code from octave-forge to octave [Was: polyderiv problem?], John W. Eaton, 2005/02/10
- Moving code from octave-forge to octave [Was: polyderiv problem?], John W. Eaton, 2005/02/10