本文整理汇总了C++中eq函数的典型用法代码示例。如果您正苦于以下问题:C++ eq函数的具体用法?C++ eq怎么用?C++ eq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_reg5
int test_reg5(void *state) {
errr r = parser_reg(state, "abc str foo int bar", ignored);
eq(r, -EINVAL);
ok;
}
示例2: eq
bool operator==(const image_transform& lhs, const image_transform& rhs)
{
return eq(lhs.opacity, rhs.opacity) && eq(lhs.contrast, rhs.contrast) && eq(lhs.brightness, rhs.brightness) &&
eq(lhs.saturation, rhs.saturation) && boost::range::equal(lhs.anchor, rhs.anchor, eq) &&
boost::range::equal(lhs.fill_translation, rhs.fill_translation, eq) &&
boost::range::equal(lhs.fill_scale, rhs.fill_scale, eq) &&
boost::range::equal(lhs.clip_translation, rhs.clip_translation, eq) &&
boost::range::equal(lhs.clip_scale, rhs.clip_scale, eq) && eq(lhs.angle, rhs.angle) &&
lhs.is_key == rhs.is_key && lhs.invert == rhs.invert && lhs.is_mix == rhs.is_mix &&
lhs.blend_mode == rhs.blend_mode && lhs.layer_depth == rhs.layer_depth &&
lhs.chroma.enable == rhs.chroma.enable && lhs.chroma.show_mask == rhs.chroma.show_mask &&
eq(lhs.chroma.target_hue, rhs.chroma.target_hue) && eq(lhs.chroma.hue_width, rhs.chroma.hue_width) &&
eq(lhs.chroma.min_saturation, rhs.chroma.min_saturation) &&
eq(lhs.chroma.min_brightness, rhs.chroma.min_brightness) && eq(lhs.chroma.softness, rhs.chroma.softness) &&
eq(lhs.chroma.spill_suppress, rhs.chroma.spill_suppress) &&
eq(lhs.chroma.spill_suppress_saturation, rhs.chroma.spill_suppress_saturation) && lhs.crop == rhs.crop &&
lhs.perspective == rhs.perspective;
}
示例3: CglProbingUnitTest
//--------------------------------------------------------------------------
// test EKKsolution methods.
void
CglProbingUnitTest(
const OsiSolverInterface * baseSiP,
const std::string mpsDir )
{
# ifdef CGL_DEBUG
int i ; // define just once
# endif
CoinRelFltEq eq(0.000001);
// Test default constructor
{
CglProbing aGenerator;
}
// Test copy & assignment
{
CglProbing rhs;
{
CglProbing bGenerator;
CglProbing cGenerator(bGenerator);
rhs=bGenerator;
}
}
{
OsiCuts osicuts;
CglProbing test1;
OsiSolverInterface * siP = baseSiP->clone();
int nColCuts;
int nRowCuts;
std::string fn = mpsDir+"p0033";
siP->readMps(fn.c_str(),"mps");
siP->initialSolve();
// just unsatisfied variables
test1.generateCuts(*siP,osicuts);
nColCuts = osicuts.sizeColCuts();
nRowCuts = osicuts.sizeRowCuts();
std::cout<<"There are "<<nRowCuts<<" probing cuts"<<std::endl;
{
std::cout<<"there are "<<nColCuts<<" probing column cuts"<<std::endl;
#ifdef CGL_DEBUG
const double * lo = siP->getColLower();
const double * up = siP->getColUpper();
for (i=0; i<nColCuts; i++){
OsiColCut ccut;
CoinPackedVector cpv;
ccut = osicuts.colCut(i);
cpv = ccut.lbs();
int n = cpv.getNumElements();
int j;
const int * indices = cpv.getIndices();
double* elements = cpv.getElements();
for (j=0;j<n;j++) {
int icol=indices[j];
if (elements[j]>lo[icol])
std::cout<<"Can increase lb on "<<icol<<" from "<<lo[icol]<<
" to "<<elements[j]<<std::endl;
}
cpv = ccut.ubs();
n = cpv.getNumElements();
indices = cpv.getIndices();
elements = cpv.getElements();
for (j=0;j<n;j++) {
int icol=indices[j];
if (elements[j]<up[icol])
std::cout<<"Can decrease ub on "<<icol<<" from "<<up[icol]<<
" to "<<elements[j]<<std::endl;
}
}
#endif
}
#ifdef CGL_DEBUG
for (i=0; i<nRowCuts; i++){
OsiRowCut rcut;
CoinPackedVector rpv;
const double * colsol = siP->getColSolution();
rcut = osicuts.rowCut(i);
rpv = rcut.row();
const int n = rpv.getNumElements();
const int * indices = rpv.getIndices();
double* elements = rpv.getElements();
double sum2=0.0;
int k=0;
double lb=rcut.lb();
double ub=rcut.ub();
for (k=0; k<n; k++){
int column=indices[k];
sum2 += colsol[column]*elements[k];
}
if (sum2 >ub + 1.0e-7 ||sum2 < lb - 1.0e-7) {
std::cout<<"Cut "<<i<<" lb "<<lb<<" solution "<<sum2<<" ub "<<ub<<std::endl;
//.........这里部分代码省略.........
示例4: test_negative
static int test_negative(void *state) {
errr r = parser_parse(state, "M:F:-1");
eq(r, PARSE_ERROR_INVALID_VALUE);
ok;
}
示例5: mc_malloc
cue_t *cue_new(const char *file)
{
cue_t *r = (cue_t *) mc_malloc(sizeof(cue_t));
r->audio_file = NULL;
r->album_title = NULL;
r->album_performer = NULL;
r->album_composer = NULL;
r->genre = NULL;
r->cuefile = mystrdup(file);
r->count = 0;
r->entries = NULL;
r->_errno = 0;
FILE *f = fopen(file, "rt");
time_t _audio_mtime=0;
if (f == NULL) {
r->_errno = ENOFILECUE;
} else {
char *line;
char *image = NULL;
char *year = NULL;
cue_entry_t *entry = NULL;
int in_tracks = 0;
while ((line = readline(f)) != NULL) {
trim_replace(&line);
if (strcmp(line, "") != 0) {
if (!in_tracks) {
if (eq(line, "performer")) {
mc_free(r->album_performer);
r->album_performer = unquote(line, "performer");
} else if (eq(line, "title")) {
mc_free(r->album_title);
r->album_title = unquote(line, "title");
} else if (eq(line, "file")) {
mc_free(r->audio_file);
char *fl = getFilePart(line);
char *af = unquote(fl, "");
if (strlen(af) > 0) {
if (af[0] == '/') {
r->audio_file = af;
} else {
char *cf = mc_strdup(r->cuefile);
int ii;
for (ii = strlen(cf) - 1; ii >= 0 && cf[ii] != '/'; ii--) ;
if (ii >= 0) {
cf[ii] = '\0';
char *aaf = (char *)mc_malloc(strlen(cf) + strlen(af) + strlen("/") + 1);
sprintf(aaf, "%s/%s", cf, af);
r->audio_file = aaf;
mc_free(cf);
mc_free(af);
} else {
r->audio_file = af;
}
}
} else {
r->audio_file = af;
}
// We have a full path audio file now.
// get the mtime.
{
struct stat st;
stat(r->audio_file,&st);
_audio_mtime=st.st_mtime;
}
mc_free(fl);
} else if (eq(line, "rem")) {
if (eq(&line[3], "date")) {
mc_free(year);
year = unquote(&line[3], "date");
} else if (eq(&line[3], "image")) {
mc_free(image);
image = unquote(&line[3], "image");
} else if (eq(&line[3], "composer")) {
mc_free(r->album_composer);
r->album_performer = unquote(&line[3], "composer");
} else if (eq(&line[3], "genre")) {
mc_free(r->genre);
r->genre = unquote(&line[3], "genre");
}
} else if (eq(line, "track")) {
in_tracks = 1;
}
}
if (in_tracks) {
if (eq(line, "track")) {
log_debug2("track: entry=%p", entry);
if (entry != NULL) {
addEntry(r, entry);
}
entry = cue_entry_new(r);
entry->audio_mtime=_audio_mtime;
entry->year = mystrdup(year);
entry->performer = mystrdup(r->album_performer);
entry->composer = mystrdup(r->album_composer);
entry->piece = NULL;
//.........这里部分代码省略.........
示例6: CglKnapsackCoverUnitTest
//--------------------------------------------------------------------------
void
CglKnapsackCoverUnitTest(
const OsiSolverInterface * baseSiP,
const std::string mpsDir )
{
int i;
CoinRelFltEq eq(0.000001);
// Test default constructor
{
CglKnapsackCover kccGenerator;
}
// Test copy & assignment
{
CglKnapsackCover rhs;
{
CglKnapsackCover kccGenerator;
CglKnapsackCover cgC(kccGenerator);
rhs=kccGenerator;
}
}
// test exactSolveKnapsack
{
CglKnapsackCover kccg;
const int n=7;
double c=50;
double p[n] = {70,20,39,37,7,5,10};
double w[n] = {31, 10, 20, 19, 4, 3, 6};
double z;
int x[n];
int exactsol = kccg.exactSolveKnapsack(n, c, p, w, z, x);
assert(exactsol==1);
assert (z == 107);
assert (x[0]==1);
assert (x[1]==0);
assert (x[2]==0);
assert (x[3]==1);
assert (x[4]==0);
assert (x[5]==0);
assert (x[6]==0);
}
/*
// Testcase /u/rlh/osl2/mps/scOneInt.mps
// Model has 3 continous, 2 binary, and 1 general
// integer variable.
{
OsiSolverInterface * siP = baseSiP->clone();
int * complement=NULL;
double * xstar=NULL;
siP->readMps("../Mps/scOneInt","mps");
CglKnapsackCover kccg;
int nCols=siP->getNumCols();
// Test the siP methods for detecting
// variable type
int numCont=0, numBinary=0, numIntNonBinary=0, numInt=0;
for (int thisCol=0; thisCol<nCols; thisCol++) {
if ( siP->isContinuous(thisCol) ) numCont++;
if ( siP->isBinary(thisCol) ) numBinary++;
if ( siP->isIntegerNonBinary(thisCol) ) numIntNonBinary++;
if ( siP->isInteger(thisCol) ) numInt++;
}
assert(numCont==3);
assert(numBinary==2);
assert(numIntNonBinary==1);
assert(numInt==3);
// Test initializeCutGenerator
siP->initialSolve();
assert(xstar !=NULL);
for (i=0; i<nCols; i++){
assert(complement[i]==0);
}
int nRows=siP->getNumRows();
for (i=0; i<nRows; i++){
int vectorsize = siP->getMatrixByRow()->vectorSize(i);
assert(vectorsize==2);
}
kccg.cleanUpCutGenerator(complement,xstar);
delete siP;
}
*/
// Testcase /u/rlh/osl2/mps/tp3.mps
// Models has 3 cols, 3 rows
// Row 0 yields a knapsack, others do not.
{
// setup
OsiSolverInterface * siP = baseSiP->clone();
std::string fn(mpsDir+"tp3");
siP->readMps(fn.c_str(),"mps");
// All integer variables should be binary.
//.........这里部分代码省略.........
示例7: inp_nutsource
//.........这里部分代码省略.........
(void) cp_evloop(dd->li_line);
}
tfree(dd->li_line);
tfree(dd);
}
} else {
for (dd = deck->li_next; dd; dd = ld->li_next) {
if ((dd->li_line[0] == '*') && (dd->li_line[1] != '#')) {
ld = dd;
continue;
}
(void) strncpy(name, dd->li_line, BSIZE_SP);
for (s = name; *s && isspace(*s); s++)
;
for (t = s; *t && !isspace(*t); t++)
;
*t = '\0';
if (ciprefix(".control", dd->li_line)) {
ld->li_next = dd->li_next;
tfree(dd->li_line);
tfree(dd);
if (commands)
fprintf(cp_err, "Warning: redundant .control line\n");
else
commands = TRUE;
} else if (ciprefix(".endc", dd->li_line)) {
ld->li_next = dd->li_next;
tfree(dd->li_line);
tfree(dd);
if (commands)
commands = FALSE;
else
fprintf(cp_err, "Warning: misplaced .endc line\n");
} else if (commands || prefix("*#", dd->li_line)) {
controls = wl_cons(NULL, controls);
wl = controls;
if (prefix("*#", dd->li_line))
wl->wl_word = copy(dd->li_line + 2);
else
wl->wl_word = dd->li_line;
ld->li_next = dd->li_next;
tfree(dd);
} else if (!*dd->li_line) {
/* So blank lines in com files don't get
* considered as circuits.
*/
ld->li_next = dd->li_next;
tfree(dd->li_line);
tfree(dd);
} else {
inp_casefix(s);
inp_casefix(dd->li_line);
if (eq(s, ".width") || ciprefix(".four", s) ||
eq(s, ".plot") ||
eq(s, ".print") ||
eq(s, ".save"))
{
wl_append_word(&wl, &end, copy(dd->li_line));
ld->li_next = dd->li_next;
tfree(dd->li_line);
tfree(dd);
} else {
ld = dd;
}
}
}
if (deck->li_next) {
/* There is something left after the controls. */
fprintf(cp_out, "\nCircuit: %s\n\n", tt);
fprintf(stderr, "\nCircuit: %s\n\n", tt);
/* Now expand subcircuit macros. Note that we have to
* fix the case before we do this but after we
* deal with the commands.
*/
if (!cp_getvar("nosubckt", CP_BOOL, NULL))
deck->li_next = inp_subcktexpand(deck->li_next);
deck->li_actual = realdeck;
nutinp_dodeck(deck, tt, wl, FALSE, options, filename);
}
/* Now that the deck is loaded, do the commands... */
controls = wl_reverse(controls);
for (wl = controls; wl; wl = wl->wl_next)
(void) cp_evloop(wl->wl_word);
wl_free(controls);
}
/* Now reset everything. Pop the control stack, and fix up the IO
* as it was before the source.
*/
cp_popcontrol();
cp_curin = lastin;
cp_curout = lastout;
cp_curerr = lasterr;
tfree(tt);
}
示例8: doset
void
/*ARGSUSED*/
doset(Char **v, struct command *t)
{
Char *p;
Char *vp, op;
Char **vecp;
bool hadsub;
int subscr;
v++;
p = *v++;
if (p == 0) {
prvars();
return;
}
do {
hadsub = 0;
vp = p;
if (letter(*p))
for (; alnum(*p); p++)
continue;
if (vp == p || !letter(*vp))
stderror(ERR_NAME | ERR_VARBEGIN);
if ((p - vp) > MAXVARLEN) {
stderror(ERR_NAME | ERR_VARTOOLONG);
return;
}
if (*p == '[') {
hadsub++;
p = getinx(p, &subscr);
}
if ((op = *p) != '\0') {
*p++ = 0;
if (*p == 0 && *v && **v == '(')
p = *v++;
}
else if (*v && eq(*v, STRequal)) {
op = '=', v++;
if (*v)
p = *v++;
}
if (op && op != '=')
stderror(ERR_NAME | ERR_SYNTAX);
if (eq(p, STRLparen)) {
Char **e = v;
if (hadsub)
stderror(ERR_NAME | ERR_SYNTAX);
for (;;) {
if (!*e)
stderror(ERR_NAME | ERR_MISSING, ')');
if (**e == ')')
break;
e++;
}
p = *e;
*e = 0;
vecp = saveblk(v);
set1(vp, vecp, &shvhed);
*e = p;
v = e + 1;
}
else if (hadsub)
asx(vp, subscr, Strsave(p));
else
set(vp, Strsave(p));
if (eq(vp, STRpath)) {
exportpath(adrof(STRpath)->vec);
dohash(NULL, NULL);
}
else if (eq(vp, STRhistchars)) {
Char *pn = value(STRhistchars);
HIST = *pn++;
HISTSUB = *pn;
}
else if (eq(vp, STRuser)) {
Setenv(STRUSER, value(vp));
Setenv(STRLOGNAME, value(vp));
}
else if (eq(vp, STRwordchars)) {
word_chars = value(vp);
}
else if (eq(vp, STRterm))
Setenv(STRTERM, value(vp));
else if (eq(vp, STRhome)) {
Char *cp;
cp = Strsave(value(vp)); /* get the old value back */
/*
* convert to canonical pathname (possibly resolving symlinks)
*/
cp = dcanon(cp, cp);
set(vp, Strsave(cp)); /* have to save the new val */
/* and now mirror home with HOME */
Setenv(STRHOME, cp);
//.........这里部分代码省略.........
示例9: eq
bool operator<(const point& a, const point& b){
return eq(a.x, b.x) ? lt(a.y, b.y) : lt(a.x, b.x);
}
示例10: ne
template <typename T> bool ne (T x_, T y_, T round_) {return ! eq (x_, y_, round_);}
示例11: dolet
void
/*ARGSUSED*/
dolet(Char **v, struct command *t)
{
Char *p;
Char *vp, c, op;
bool hadsub;
int subscr;
v++;
p = *v++;
if (p == 0) {
prvars();
return;
}
do {
hadsub = 0;
vp = p;
if (letter(*p))
for (; alnum(*p); p++)
continue;
if (vp == p || !letter(*vp))
stderror(ERR_NAME | ERR_VARBEGIN);
if ((p - vp) > MAXVARLEN)
stderror(ERR_NAME | ERR_VARTOOLONG);
if (*p == '[') {
hadsub++;
p = getinx(p, &subscr);
}
if (*p == 0 && *v)
p = *v++;
if ((op = *p) != '\0')
*p++ = 0;
else
stderror(ERR_NAME | ERR_ASSIGN);
if (*p == '\0' && *v == NULL)
stderror(ERR_NAME | ERR_ASSIGN);
vp = Strsave(vp);
if (op == '=') {
c = '=';
p = xset(p, &v);
}
else {
c = *p++;
if (any("+-", c)) {
if (c != op || *p)
stderror(ERR_NAME | ERR_UNKNOWNOP);
p = Strsave(STR1);
}
else {
if (any("<>", op)) {
if (c != op)
stderror(ERR_NAME | ERR_UNKNOWNOP);
c = *p++;
stderror(ERR_NAME | ERR_SYNTAX);
}
if (c != '=')
stderror(ERR_NAME | ERR_UNKNOWNOP);
p = xset(p, &v);
}
}
if (op == '=')
if (hadsub)
asx(vp, subscr, p);
else
set(vp, p);
else if (hadsub) {
struct varent *gv = getvx(vp, subscr);
asx(vp, subscr, operate(op, gv->vec[subscr - 1], p));
}
else
set(vp, operate(op, value(vp), p));
if (eq(vp, STRpath)) {
exportpath(adrof(STRpath)->vec);
dohash(NULL, NULL);
}
xfree((ptr_t) vp);
if (c != '=')
xfree((ptr_t) p);
} while ((p = *v++) != NULL);
}
示例12: test_reg_str
int test_reg_str(void *state) {
errr r = parser_reg(state, "test-reg-str str baz", ignored);
eq(r, 0);
ok;
}
示例13: test_reg_sym
int test_reg_sym(void *state) {
errr r = parser_reg(state, "test-reg-sym sym bar", ignored);
eq(r, 0);
ok;
}
示例14: test_reg_int
int test_reg_int(void *state) {
errr r = parser_reg(state, "test-reg-int int foo", ignored);
eq(r, 0);
ok;
}
示例15: forscan
/* search forward for a <patrn> */
int
forscan(int *wrapt, /* boolean indicating search wrapped */
UCS *patrn, /* string to scan for */
LINE *limitp, /* stop searching if reached */
int limito, /* stop searching if reached */
int leavep) /* place to leave point
PTBEG = begining of match
PTEND = at end of match */
{
LINE *curline; /* current line during scan */
int curoff; /* position within current line */
LINE *lastline; /* last line position during scan */
int lastoff; /* position within last line */
UCS c; /* character at current position */
LINE *matchline; /* current line during matching */
int matchoff; /* position in matching line */
UCS *patptr; /* pointer into pattern */
int stopoff; /* offset to stop search */
LINE *stopline; /* line to stop search */
*wrapt = FALSE;
/*
* the idea is to set the character to end the search at the
* next character in the buffer. thus, let the search wrap
* completely around the buffer.
*
* first, test to see if we are at the end of the line,
* otherwise start searching on the next character.
*/
if(curwp->w_doto == llength(curwp->w_dotp)){
/*
* dot is not on end of a line
* start at 0 offset of the next line
*/
stopoff = curoff = 0;
stopline = curline = lforw(curwp->w_dotp);
if (curwp->w_dotp == curbp->b_linep)
*wrapt = TRUE;
}
else{
stopoff = curoff = curwp->w_doto;
stopline = curline = curwp->w_dotp;
}
/* scan each character until we hit the head link record */
/*
* maybe wrapping is a good idea
*/
while (curline){
if (curline == curbp->b_linep)
*wrapt = TRUE;
/* save the current position in case we need to
restore it on a match */
lastline = curline;
lastoff = curoff;
/* get the current character resolving EOLs */
if (curoff == llength(curline)) { /* if at EOL */
curline = lforw(curline); /* skip to next line */
curoff = 0;
c = '\n'; /* and return a <NL> */
}
else
c = lgetc(curline, curoff++).c; /* get the char */
/* test it against first char in pattern */
if (eq(c, patrn[0]) != FALSE) { /* if we find it..*/
/* setup match pointers */
matchline = curline;
matchoff = curoff;
patptr = &patrn[0];
/* scan through patrn for a match */
while (*++patptr != '\0') {
/* advance all the pointers */
if (matchoff == llength(matchline)) {
/* advance past EOL */
matchline = lforw(matchline);
matchoff = 0;
c = '\n';
} else
c = lgetc(matchline, matchoff++).c;
if(matchline == limitp && matchoff == limito)
return(FALSE);
/* and test it against the pattern */
if (eq(*patptr, c) == FALSE)
goto fail;
}
/* A SUCCESSFULL MATCH!!! */
/* reset the global "." pointers */
//.........这里部分代码省略.........