Mercurial > hg > octave-nkf
comparison src/npsol.cc @ 945:a1b0080599e5
[project @ 1994-11-21 21:56:42 by jwe]
author | jwe |
---|---|
date | Mon, 21 Nov 1994 21:56:55 +0000 |
parents | e81d3a66725e |
children | dfe01093f657 |
comparison
equal
deleted
inserted
replaced
944:2e954ce5263f | 945:a1b0080599e5 |
---|---|
356 goto solved; | 356 goto solved; |
357 } | 357 } |
358 | 358 |
359 npsol_constraints = 0; | 359 npsol_constraints = 0; |
360 if (nargin == 5 || nargin == 7 || nargin == 8 || nargin == 10) | 360 if (nargin == 5 || nargin == 7 || nargin == 8 || nargin == 10) |
361 npsol_constraints = is_valid_function (args(nargin-1), "npsol", 0); | 361 npsol_constraints = is_valid_function (args(nargin-2), "npsol", 0); |
362 | 362 |
363 if (nargin == 7 || nargin == 5) | 363 if (nargin == 7 || nargin == 5) |
364 { | 364 { |
365 if (! npsol_constraints) | 365 if (! npsol_constraints) |
366 { | 366 { |
367 ColumnVector lub = args(nargin).vector_value (); | 367 ColumnVector lub = args(nargin-1).vector_value (); |
368 ColumnVector llb = args(nargin-2).vector_value (); | 368 ColumnVector llb = args(nargin-3).vector_value (); |
369 | 369 |
370 if (error_state || llb.capacity () == 0 || lub.capacity () == 0) | 370 if (error_state || llb.capacity () == 0 || lub.capacity () == 0) |
371 { | 371 { |
372 error ("npsol: bounds for linear constraints must be vectors"); | 372 error ("npsol: bounds for linear constraints must be vectors"); |
373 return retval; | 373 return retval; |
374 } | 374 } |
375 | 375 |
376 Matrix c = args(nargin-1).matrix_value (); | 376 Matrix c = args(nargin-2).matrix_value (); |
377 | 377 |
378 if (error_state) | 378 if (error_state) |
379 { | 379 { |
380 error ("npsol: invalid linear constraint matrix"); | 380 error ("npsol: invalid linear constraint matrix"); |
381 return retval; | 381 return retval; |
406 } | 406 } |
407 else | 407 else |
408 { | 408 { |
409 if (takes_correct_nargs (npsol_constraints, 1, "npsol", 1)) | 409 if (takes_correct_nargs (npsol_constraints, 1, "npsol", 1)) |
410 { | 410 { |
411 ColumnVector nlub = args(nargin).vector_value (); | 411 ColumnVector nlub = args(nargin-1).vector_value (); |
412 ColumnVector nllb = args(nargin-2).vector_value (); | 412 ColumnVector nllb = args(nargin-3).vector_value (); |
413 | 413 |
414 if (error_state | 414 if (error_state |
415 || (! nonlinear_constraints_ok | 415 || (! nonlinear_constraints_ok |
416 (x, nllb, npsol_constraint_function, nlub, "npsol", 1))) | 416 (x, nllb, npsol_constraint_function, nlub, "npsol", 1))) |
417 return retval; | 417 return retval; |
443 if (nargin == 8 || nargin == 10) | 443 if (nargin == 8 || nargin == 10) |
444 { | 444 { |
445 if (! npsol_constraints) | 445 if (! npsol_constraints) |
446 { | 446 { |
447 // Produce error message. | 447 // Produce error message. |
448 is_valid_function (args(nargin-1), "npsol", 1); | 448 is_valid_function (args(nargin-2), "npsol", 1); |
449 } | 449 } |
450 else | 450 else |
451 { | 451 { |
452 if (takes_correct_nargs (npsol_constraints, 1, "npsol", 1)) | 452 if (takes_correct_nargs (npsol_constraints, 1, "npsol", 1)) |
453 { | 453 { |
454 ColumnVector nlub = args(nargin).vector_value (); | 454 ColumnVector nlub = args(nargin-1).vector_value (); |
455 ColumnVector nllb = args(nargin-2).vector_value (); | 455 ColumnVector nllb = args(nargin-3).vector_value (); |
456 | 456 |
457 if (error_state | 457 if (error_state |
458 || (! nonlinear_constraints_ok | 458 || (! nonlinear_constraints_ok |
459 (x, nllb, npsol_constraint_function, nlub, "npsol", 1))) | 459 (x, nllb, npsol_constraint_function, nlub, "npsol", 1))) |
460 return retval; | 460 return retval; |
461 | 461 |
462 NLFunc const_func (npsol_constraint_function); | 462 NLFunc const_func (npsol_constraint_function); |
463 NLConst nonlinear_constraints (nllb, const_func, nlub); | 463 NLConst nonlinear_constraints (nllb, const_func, nlub); |
464 | 464 |
465 ColumnVector lub = args(nargin-3).vector_value (); | 465 ColumnVector lub = args(nargin-4).vector_value (); |
466 ColumnVector llb = args(nargin-5).vector_value (); | 466 ColumnVector llb = args(nargin-6).vector_value (); |
467 | 467 |
468 if (error_state || llb.capacity () == 0 || lub.capacity () == 0) | 468 if (error_state || llb.capacity () == 0 || lub.capacity () == 0) |
469 { | 469 { |
470 error ("npsol: bounds for linear constraints must be vectors"); | 470 error ("npsol: bounds for linear constraints must be vectors"); |
471 return retval; | 471 return retval; |
472 } | 472 } |
473 | 473 |
474 Matrix c = args(nargin-4).matrix_value (); | 474 Matrix c = args(nargin-5).matrix_value (); |
475 | 475 |
476 if (error_state) | 476 if (error_state) |
477 { | 477 { |
478 error ("npsol: invalid linear constraint matrix"); | 478 error ("npsol: invalid linear constraint matrix"); |
479 return retval; | 479 return retval; |