Skip to content

Commit

Permalink
240203.213512.HKT Move #include "prima/prima.h" to the top of the c…
Browse files Browse the repository at this point in the history
… files, according to 6aefe01#r138135604
  • Loading branch information
zaikunzhang committed Feb 3, 2024
1 parent a95f7d2 commit 1e6bbd8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
6 changes: 4 additions & 2 deletions c/examples/bobyqa/bobyqa_example.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// An example to illustrate the use of BOBYQA.


#include "prima/prima.h"
#include <math.h>
#include <stdio.h>

// Make PRIMA available
#include "prima/prima.h"

// Objective function
static void fun(const double x[], double *f, const void *data)
Expand All @@ -15,6 +15,7 @@ static void fun(const double x[], double *f, const void *data)
(void)data;
}


// Callback function
static void callback(int n, const double x[], double f, int nf, int tr, double cstrv, const int m_nlcon, const double nlconstr[], bool *terminate)
{
Expand All @@ -26,6 +27,7 @@ static void callback(int n, const double x[], double f, int nf, int tr, double c
*terminate = 0;
}


// Main function
int main(int argc, char * argv[])
{
Expand Down
7 changes: 5 additions & 2 deletions c/examples/cobyla/cobyla_example.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// An example to illustrate the use of COBYLA.


#include "prima/prima.h"
#include <math.h>
#include <stdint.h>
#include <stdio.h>

// Make PRIMA available
#include "prima/prima.h"

#define M_NLCON 1
#define PROVIDE_INITIAL_F_AND_NLCONSTR 1


// Objective & constraint function
static void fun(const double x[], double *f, double constr[], const void *data)
{
Expand All @@ -20,6 +21,7 @@ static void fun(const double x[], double *f, double constr[], const void *data)
(void)data;
}


// Callback function
static void callback(const int n, const double x[], const double f, const int nf, const int tr, const double cstrv, const int m_nlcon, const double nlconstr[], bool *terminate)
{
Expand All @@ -29,6 +31,7 @@ static void callback(const int n, const double x[], const double f, const int nf
*terminate = 0;
}


// Main function
int main(int argc, char * argv[])
{
Expand Down
6 changes: 4 additions & 2 deletions c/examples/lincoa/lincoa_example.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// An example to illustrate the use of LINCOA.


#include "prima/prima.h"
#include <math.h>
#include <stdio.h>

// Make PRIMA available
#include "prima/prima.h"

// Objective function
static void fun(const double x[], double *f, const void *data)
Expand All @@ -15,6 +15,7 @@ static void fun(const double x[], double *f, const void *data)
(void)data;
}


// Callback function
static void callback(int n, const double x[], double f, int nf, int tr, double cstrv, int m_nlcon, const double nlconstr[], bool *terminate)
{
Expand All @@ -25,6 +26,7 @@ static void callback(int n, const double x[], double f, int nf, int tr, double c
*terminate = 0;
}


// Main function
int main(int argc, char * argv[])
{
Expand Down
6 changes: 4 additions & 2 deletions c/examples/newuoa/newuoa_example.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// An example to illustrate the use of NEWUOA.


#include "prima/prima.h"
#include <math.h>
#include <stdio.h>

// Make PRIMA available
#include "prima/prima.h"

// Objective function
static void fun(const double x[], double *f, const void *data)
Expand All @@ -15,6 +15,7 @@ static void fun(const double x[], double *f, const void *data)
(void)data;
}


// Callback function
static void callback(int n, const double x[], double f, int nf, int tr, double cstrv, int m_nlcon, const double nlconstr[], bool *terminate)
{
Expand All @@ -26,6 +27,7 @@ static void callback(int n, const double x[], double f, int nf, int tr, double c
*terminate = 0;
}


// Main function
int main(int argc, char * argv[])
{
Expand Down
6 changes: 4 additions & 2 deletions c/examples/uobyqa/uobyqa_example.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// An example to illustrate the use of UOBYQA.


#include "prima/prima.h"
#include <math.h>
#include <stdio.h>

// Make PRIMA available
#include "prima/prima.h"

// Objective function
static void fun(const double x[], double *f, const void *data)
Expand All @@ -15,6 +15,7 @@ static void fun(const double x[], double *f, const void *data)
(void)data;
}


// Callback function
static void callback(int n, const double x[], double f, int nf, int tr, double cstrv, const int m_nlcon, const double nlconstr[], bool *terminate)
{
Expand All @@ -26,6 +27,7 @@ static void callback(int n, const double x[], double f, int nf, int tr, double c
*terminate = 0;
}


// Main function
int main(int argc, char * argv[])
{
Expand Down
4 changes: 2 additions & 2 deletions c/prima.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Dedicated to the late Professor M. J. D. Powell FRS (1936--2015).


#include "prima/prima.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "prima/prima.h"


/*
* A NOTE ON DEFAULT VALUES IN OPTIONS AND PROBLEM STRUCTURES
Expand Down

0 comments on commit 1e6bbd8

Please sign in to comment.