How can I assign an infinity in GAUSS?

How can I assign an infinity in GAUSS?

3 Answers



0



accepted

__infp is positive infinity and __infn is negative infinity.

aptech

1,773


0



Hi, when I want to assign a infn to a element of a matrix, I got syntax error message. May I know where goes wrong?

c0= {-10 10, __infn __infp};



0



Matrix definition statements like

x = { 1 2,
      3 4 };

x = { 1 2 3 4 };

x = { 1,
      2,
      3,
      4 };

// __INFP is technically a variable
// so it cannot be part of a matrix
// declaration
x = { 1 2 __INFP };

can only accept constant values. The reason for this is that the matrix definition gets embedded in the compiled program.

Your example looks like setting bounds for parameters in an optimization problem. In this case, I would not be afraid to use a large number like 1e256 or -1e256. If your parameters ever get this extreme, you will almost certainly have significant numerical problems. So for this case

c0 = {-10 10, -1e256 1e256 };

is probably the best solution. However, in a different case where you do need to add in a value from a variable and the matrix is large enough that you do not want to manually assign it, you could put placeholders in the matrix and use the missrv or reclassify functions. For example

// If we only have 1 placeholder,
// we can use a missing value
// A dot '.' in a matrix definition
// will create a missing value
x = { 1 2,
      . . };

// Replace missing values with __infp
x2 = missrv(x, __infp);
print "x2 = " x2;

// Use out-of-range values to create
// placeholders for more than one substitution
// Assuming our matrix will only have positive values
x = { 1.5 2.2,
      -1   -2 };
x3 = reclassify(x, -1|-2, __infn|__infp);
print "x3 = " x3;

// If the range of numbers in the matrix
// is very wide, you can embed character placeholders
// in the matrix like this
x = {  1   2,
     "a" "b" };

// Notice we use the matrix concatenation operator
// '|' instead of the string concat operator '$|'
// to tell GAUSS to make a numeric vector with
// embedded characters
x4 = reclassify(x, "a" | "b", __infn | __infp);
print "x4 = " x4;

aptech

1,773

Your Answer

3 Answers

0
accepted

__infp is positive infinity and __infn is negative infinity.

0

Hi, when I want to assign a infn to a element of a matrix, I got syntax error message. May I know where goes wrong?

c0= {-10 10, __infn __infp};

0

Matrix definition statements like

x = { 1 2,
      3 4 };

x = { 1 2 3 4 };

x = { 1,
      2,
      3,
      4 };

// __INFP is technically a variable
// so it cannot be part of a matrix
// declaration
x = { 1 2 __INFP };

can only accept constant values. The reason for this is that the matrix definition gets embedded in the compiled program.

Your example looks like setting bounds for parameters in an optimization problem. In this case, I would not be afraid to use a large number like 1e256 or -1e256. If your parameters ever get this extreme, you will almost certainly have significant numerical problems. So for this case

c0 = {-10 10, -1e256 1e256 };

is probably the best solution. However, in a different case where you do need to add in a value from a variable and the matrix is large enough that you do not want to manually assign it, you could put placeholders in the matrix and use the missrv or reclassify functions. For example

// If we only have 1 placeholder,
// we can use a missing value
// A dot '.' in a matrix definition
// will create a missing value
x = { 1 2,
      . . };

// Replace missing values with __infp
x2 = missrv(x, __infp);
print "x2 = " x2;

// Use out-of-range values to create
// placeholders for more than one substitution
// Assuming our matrix will only have positive values
x = { 1.5 2.2,
      -1   -2 };
x3 = reclassify(x, -1|-2, __infn|__infp);
print "x3 = " x3;

// If the range of numbers in the matrix
// is very wide, you can embed character placeholders
// in the matrix like this
x = {  1   2,
     "a" "b" };

// Notice we use the matrix concatenation operator
// '|' instead of the string concat operator '$|'
// to tell GAUSS to make a numeric vector with
// embedded characters
x4 = reclassify(x, "a" | "b", __infn | __infp);
print "x4 = " x4;


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.