[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
some more uint8 woes...
From: |
Brian Blais |
Subject: |
some more uint8 woes... |
Date: |
Sat, 12 Mar 2005 11:47:38 -0500 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040913) |
Hello,
I am still having some problems dealing with uint8 types. In my
application, I want to be able to pass in either a regular (double)
matrix or a uint8 matrix, copy values from the matrix to another
(double) matrix but (due to size) not convert the entire original
matrix. For example, I want to be able to pass in a large 500x500x300
matrix, and get smaller pieces on the order of 20x20 out of the larger
one. I wrote a simple program to play with some of the uint8
properties, but get an error I don't understand. I'm using octave
version 2.1.64 in Linux. The simple code below takes in a matrix,
returns the first value of the matrix as a double Matrix (1x1) value.
It works for the uint8 case, but breaks with the double case like:
a=example_uint8(uint8(20))
here
retval = 20
a = 20
a=example_uint8(20)
error: octave_base_value::uint8_array_value(): wrong type argument `scalar'
here
retval = 20
error: evaluating assignment expression near line 28, column 2
any ideas? am I doing something stupid here? naturally, I will scale
this example up for my application, but this is the simplest example
which reproduces the error.
thanks,
Brian Blais
#include <octave/oct.h>
DEFUN_DLD (example_uint8, args, nargout,
"example_uint8.") {
octave_value_list retval; // #1
uint8NDArray uint8_m = args(0).uint8_array_value ();
int is_uint8=(!error_state);
NDArray double_m;
if (!is_uint8) {
double_m= args(0).array_value();
}
Matrix ret_mat(1,1,0.0);
if (is_uint8) {
ret_mat(0)=(double) uint8_m(0);
} else {
ret_mat(0)=double_m(0);
}
retval.append(ret_mat);
// some debugging printfs
retval(0).print_with_name(octave_stdout,"retval");
printf("here\n"); fflush(stdout);
return(retval);
}
--
-----------------
address@hidden
http://web.bryant.edu/~bblais
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- some more uint8 woes...,
Brian Blais <=