PIPS
hyperplane_direction.c File Reference
#include <stdio.h>
#include <strings.h>
#include "boolean.h"
#include "arithmetique.h"
#include "matrice.h"
#include "genC.h"
#include "misc.h"
+ Include dependency graph for hyperplane_direction.c:

Go to the source code of this file.

Functions

bool interactive_hyperplane_direction (Value *h, int n)
 Find out a legal hyperplane direction. More...
 

Function Documentation

◆ interactive_hyperplane_direction()

bool interactive_hyperplane_direction ( Value h,
int  n 
)

Find out a legal hyperplane direction.

hyperplane_direction.c

In a first phase, trust the user blindly!

Query the user for h's coordinates

Definition at line 40 of file hyperplane_direction.c.

41 {
42  int i;
43  int n_read;
44  string resp = string_undefined;
45  string cn = string_undefined;
46  bool return_status = false;
47 
48  /* Query the user for h's coordinates */
49  pips_assert("hyperplane_direction", n>=1);
50  debug(8, "interactive_hyperplane_direction", "Reading h\n");
51  resp = user_request("Hyperplane direction vector?\n"
52  "(give all its integer coordinates on one line): ");
53  if (resp[0] == '\0') {
54  user_log("Hyperplane loop transformation has been cancelled.\n");
55  return_status = false;
56  }
57  else {
58  cn = strtok(resp, " \t");
59 
60  return_status = true;
61  for( i = 0; i<n; i++) {
62  if(cn==NULL) {
63  user_log("Not enough coordinates. "
64  "Hyperplane loop transformation has been cancelled.\n");
65  return_status = false;
66  break;
67  }
68  n_read = sscanf(cn," " VALUE_FMT, h+i);
69  if(n_read!=1) {
70  user_log("Not enough coordinates. "
71  "Hyperplane loop transformation has been cancelled.\n");
72  return_status = false;
73  break;
74  }
75  cn = strtok(NULL, " \t");
76  }
77  }
78 
79  if(cn!=NULL) {
80  user_log("Too many coordinates. "
81  "Hyperplane loop transformation has been cancelled.\n");
82  return_status = false;
83  }
84 
85  ifdebug(8) {
86  if(return_status) {
87  pips_debug(8, "Hyperplane direction vector:\n");
88  for( i = 0; i<n; i++) {
89  (void) fprintf(stderr," " VALUE_FMT, *(h+i));
90  }
91  (void) fprintf(stderr,"\n");
92  pips_debug(8, "End\n");
93  }
94  else {
95  pips_debug(8, "Ends with failure\n");
96  }
97  }
98 
99  return return_status;
100 }
void user_log(const char *format,...)
Definition: message.c:234
#define VALUE_FMT
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
string user_request(const char *,...)
#define string_undefined
Definition: newgen_types.h:40
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47

References debug(), fprintf(), ifdebug, pips_assert, pips_debug, string_undefined, user_log(), user_request(), and VALUE_FMT.

Referenced by hyperplane().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: