/[ascend]/trunk/base/generic/solver/slv.c
ViewVC logotype

Diff of /trunk/base/generic/solver/slv.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 150 by johnpye, Thu Dec 22 09:24:56 2005 UTC revision 151 by johnpye, Thu Dec 22 10:58:33 2005 UTC
# Line 278  static int g_number_of_bnds; Line 278  static int g_number_of_bnds;
278      index is in the range [0,NORC). 'sys' should not be null      index is in the range [0,NORC). 'sys' should not be null
279      @param sys system, slv_system_t.      @param sys system, slv_system_t.
280   */   */
281  #define LS(sys) ( SNUM(sys) >= 0 && SNUM(sys) < g_SlvNumberOfRegisteredClients )  #define LS(sys) ( (sys)->solver >= 0 && (sys)->solver < g_SlvNumberOfRegisteredClients )
282    
283  /** Boolean test that i is in the range [0,NORC) */  /** Boolean test that i is in the range [0,NORC) */
284  #define LSI(i) ( (i) >= 0 && (i) < g_SlvNumberOfRegisteredClients )  #define LSI(i) ( (i) >= 0 && (i) < g_SlvNumberOfRegisteredClients )
285    
286  /** Check and return a function pointer. See @SF */  /** Check and return a function pointer. See @SF */
287  #define CF(sys,ptr) ( LS(sys) ?  SlvClientsData[SNUM(sys)].ptr : NULL )  #define CF(sys,ptr) ( LS(sys) ?  SlvClientsData[(sys)->solver].ptr : NULL )
288    
289  /** Return the pointer to the client-supplied function or char if  /** Return the pointer to the client-supplied function or char if
290      the client supplied one, else NULL. This should only be called      the client supplied one, else NULL. This should only be called
291      with nonNULL sys after CF is happy. @see CF      with nonNULL sys after CF is happy. @see CF
292  */  */
293  #define SF(sys,ptr) ( SlvClientsData[SNUM(sys)].ptr )  #define SF(sys,ptr) ( SlvClientsData[(sys)->solver].ptr )
294    
295  /** Free a pointer provided it's not NULL */  /** Free a pointer provided it's not NULL */
296  #define SFUN(p) if ((p) != NULL) ascfree(p)  #define SFUN(p) if ((p) != NULL) ascfree(p)
# Line 327  int slv_register_client(SlvRegistration Line 327  int slv_register_client(SlvRegistration
327    status = registerfunc(&( SlvClientsData[NORC]));    status = registerfunc(&( SlvClientsData[NORC]));
328    if (!status) { /* ok */    if (!status) { /* ok */
329      SlvClientsData[NORC].number = NORC;      SlvClientsData[NORC].number = NORC;
330      new_client_id = NORC;      *new_client_id = NORC;
331      NORC++;      NORC++;
332    } else {    } else {
333      FPRINTF(stderr,"Client %d registration failure (%d)!\n",NORC,status);      *new_client_id = -2;
334        error_reporter(ASC_PROG_ERR,NULL,0,"Client %d registration failure (%d)!\n",NORC,status);
335    }    }
336      /*CONSOLE_DEBUG("status: %d",status);*/
337    return status;    return status;
338  }  }
339    
# Line 1894  int slv_select_solver(slv_system_t sys,i Line 1896  int slv_select_solver(slv_system_t sys,i
1896    if ( solver >= 0 && solver < NORC ) {    if ( solver >= 0 && solver < NORC ) {
1897      if (sys->ct != NULL && solver != sys->solver) {      if (sys->ct != NULL && solver != sys->solver) {
1898        CONSOLE_DEBUG("Solver has changed, destroy old data...");        CONSOLE_DEBUG("Solver has changed, destroy old data...");
1899        destroy = SlvClientsData[SNUM(sys)].cdestroy;        destroy = SlvClientsData[sys->solver].cdestroy;
1900        if(destroy!=NULL) {        if(destroy!=NULL) {
1901          CONSOLE_DEBUG("About to destroy data...");          CONSOLE_DEBUG("About to destroy data...");
1902          (destroy)(sys,sys->ct);          (destroy)(sys,sys->ct);
# Line 1951  int slv_switch_solver(slv_system_t sys,i Line 1953  int slv_switch_solver(slv_system_t sys,i
1953  {  {
1954    int status_index;    int status_index;
1955    
1956      CONSOLE_DEBUG("SLV_SWITH_SOLVER CALLED..............................");
1957    
1958    if (sys ==NULL) {    if (sys ==NULL) {
1959      error_reporter(ASC_PROG_WARNING,NULL,0,"slv_switch_solver called with NULL system\n");      error_reporter(ASC_PROG_WARNING,NULL,0,"slv_switch_solver called with NULL system\n");
1960      return -1;      return -1;
1961    }    }
1962    if (LSI(solver)) {    if( solver >= 0 && solver < g_SlvNumberOfRegisteredClients ){
1963      status_index = solver;      status_index = solver;
1964      sys->solver = solver;      sys->solver = solver;
1965      if ( CF(sys,ccreate) != NULL) {      if ( CF(sys,ccreate) != NULL) {
# Line 2254  void slv_set_client_token(slv_system_t s Line 2258  void slv_set_client_token(slv_system_t s
2258    
2259  void slv_set_solver_index(slv_system_t sys, int solver)  void slv_set_solver_index(slv_system_t sys, int solver)
2260  {  {
2261      CONSOLE_DEBUG("======================================");
2262    
2263    if (sys==NULL) {    if (sys==NULL) {
2264      error_reporter(ASC_PROG_ERROR,NULL,0,"slv_set_solver_index called with NULL system.\n");      error_reporter(ASC_PROG_ERROR,NULL,0,"slv_set_solver_index called with NULL system.\n");
2265      return;      return;

Legend:
Removed from v.150  
changed lines
  Added in v.151

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22