Mercurial > octave-nkf
comparison libinterp/corefcn/data.cc @ 20609:780431fc4137
linspace: add tests for the use of vectors as base and limit.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Thu, 08 Oct 2015 20:06:45 +0100 |
parents | 32a0bf9906c1 |
children | ba2b07c13913 |
comparison
equal
deleted
inserted
replaced
20608:32a0bf9906c1 | 20609:780431fc4137 |
---|---|
5209 @seealso{logspace}\n\ | 5209 @seealso{logspace}\n\ |
5210 @end deftypefn") | 5210 @end deftypefn") |
5211 { | 5211 { |
5212 octave_value retval; | 5212 octave_value retval; |
5213 | 5213 |
5214 int nargin = args.length (); | 5214 octave_idx_type nargin = args.length (); |
5215 | 5215 |
5216 octave_idx_type npoints = 100; | 5216 octave_idx_type npoints = 100; |
5217 | 5217 |
5218 if (nargin != 2 && nargin != 3) | 5218 if (nargin != 2 && nargin != 3) |
5219 { | 5219 { |
5279 ## Test complex values | 5279 ## Test complex values |
5280 %!test | 5280 %!test |
5281 %! exp = [1+0i, 2-1.25i, 3-2.5i, 4-3.75i, 5-5i]; | 5281 %! exp = [1+0i, 2-1.25i, 3-2.5i, 4-3.75i, 5-5i]; |
5282 %! obs = linspace (1, 5-5i, 5); | 5282 %! obs = linspace (1, 5-5i, 5); |
5283 %! assert (obs, exp); | 5283 %! assert (obs, exp); |
5284 | |
5285 ## Test support for vectors in BASE and LIMIT | |
5286 %!assert (linspace ([1 2 3], [7 8 9]), | |
5287 %! [linspace(1, 7); linspace(2, 8); linspace(3, 9)]) | |
5288 %!assert (linspace ([1 2 3]', [7 8 9]'), | |
5289 %! [linspace(1, 7); linspace(2, 8); linspace(3, 9)]) | |
5290 %!assert (linspace ([1 2 3], 9), | |
5291 %! [linspace(1, 9); linspace(2, 9); linspace(3, 9)]) | |
5292 %!assert (linspace ([1 2 3]', 9), | |
5293 %! [linspace(1, 9); linspace(2, 9); linspace(3, 9)]) | |
5294 %!assert (linspace (1, [7 8 9]), | |
5295 %! [linspace(1, 7); linspace(1, 8); linspace(1, 9)]) | |
5296 %!assert (linspace (1, [7 8 9]'), | |
5297 %! [linspace(1, 7); linspace(1, 8); linspace(1, 9)]) | |
5284 | 5298 |
5285 ## Test class of output | 5299 ## Test class of output |
5286 %!assert (class (linspace (1, 2)), "double") | 5300 %!assert (class (linspace (1, 2)), "double") |
5287 %!assert (class (linspace (single (1), 2)), "single") | 5301 %!assert (class (linspace (single (1), 2)), "single") |
5288 %!assert (class (linspace (1, single (2))), "single") | 5302 %!assert (class (linspace (1, single (2))), "single") |