comparison src/data.cc @ 1100:3b6f6c5217e7

[project @ 1995-02-14 01:45:09 by jwe]
author jwe
date Tue, 14 Feb 1995 01:45:09 +0000
parents eb788d2f49c2
children 32fbe094cc10
comparison
equal deleted inserted replaced
1099:8a5b0b2caf44 1100:3b6f6c5217e7
956 } 956 }
957 957
958 return retval; 958 return retval;
959 } 959 }
960 960
961 DEFUN ("linspace", Flinspace, Slinspace, 2, 1,
962 "usage: linspace (x1, x2, n)\n\
963 \n\
964 Return a vector of n equally spaced points between x1 and x2\n\
965 inclusive.\n\
966 \n\
967 If the final argument is omitted, n = 100 is assumed.\n\
968 \n\
969 All three arguments must be scalars.\n\
970 \n\
971 See also: logspace")
972 {
973 Octave_object retval;
974
975 int nargin = args.length ();
976
977 int npoints = 100;
978
979 if (nargin == 3)
980 {
981 double n = args(2).double_value ();
982
983 if (! error_state)
984 npoints = NINT (n);
985 }
986 else
987 print_usage ("linspace");
988
989 if (! error_state)
990 {
991 if (npoints > 1)
992 {
993 tree_constant arg_1 = args(0);
994 tree_constant arg_2 = args(1);
995
996 if (arg_1.is_complex_type () || arg_2.is_complex_type ())
997 {
998 Complex x1 = arg_1.complex_value ();
999 Complex x2 = arg_2.complex_value ();
1000
1001 if (! error_state)
1002 {
1003 ComplexRowVector rv = linspace (x1, x2, npoints);
1004
1005 if (! error_state)
1006 retval (0) = tree_constant (rv, 0);
1007 }
1008 }
1009 else
1010 {
1011 double x1 = arg_1.double_value ();
1012 double x2 = arg_2.double_value ();
1013
1014 if (! error_state)
1015 {
1016 RowVector rv = linspace (x1, x2, npoints);
1017
1018 if (! error_state)
1019 retval (0) = tree_constant (rv, 0);
1020 }
1021 }
1022 }
1023 else
1024 error ("linspace: npoints must be greater than 2");
1025 }
1026
1027 return retval;
1028 }
1029
961 /* 1030 /*
962 ;;; Local Variables: *** 1031 ;;; Local Variables: ***
963 ;;; mode: C++ *** 1032 ;;; mode: C++ ***
964 ;;; page-delimiter: "^/\\*" *** 1033 ;;; page-delimiter: "^/\\*" ***
965 ;;; End: *** 1034 ;;; End: ***