예제 #1
0
파일: ll.c 프로젝트: bigpussy/harib_os_src
void enable_label(struct STR_LABEL *label)
{
	struct STR_VALUE value;
	UCHAR *t;

//	if (label->value.flags & VFLG_CALC) {
//		label->value.flags |= VFLG_SLFREF;
//		return;
//	}
//	init_value(&value);
//	value.label[0] = label - label0; /* for EXTERN */
//	value.scale[0] = 1;
//	value.flags |= label->value.flags & VFLG_EXTERN;
	if ((t = label->define) != NULL) {
		label->value.flags |= VFLG_CALC;
		calc_value0(&value, &t);
		if (value.flags & VFLG_SLFREF) {
			init_value(&value);
			value.flags |= VFLG_SLFREF;
		}
	} else /* if ((label->value.flags & VFLG_EXTERN) == 0) */ {
		/* EXTERNの時はすぐにENABLEになるので、ここに来るはずない */
		init_value(&value);
		value.flags |= VFLG_UNDEF;
	}
	label->value = value;
	label->value.flags |= VFLG_ENABLE;
	return;
}
예제 #2
0
파일: ggcomm.c 프로젝트: evoskuil/gsl
void
init_result (RESULT_NODE *node)
{
    node-> next         = NULL;
    node-> parent       = NULL;
    node-> scope        = NULL;
    node-> name         = NULL;
    node-> op1          = NULL;
    node-> op2          = NULL;
    node-> as           = NULL;
    node-> to           = NULL;
    node-> before       = NULL;
    node-> after        = NULL;
    node-> operand      = NULL;
    node-> script_node  = NULL;
    node-> result_node  = NULL;
    node-> macro        = NULL;
    node-> gsl_function = NULL;
    node-> argc         = 0;
    node-> argv         = NULL;
    node-> culprit      = NULL;
    node-> indent       = 0;
    node-> width        = 0;
    node-> constant     = FALSE;
    init_value (& node-> value);
}
예제 #3
0
  BASKER_INLINE
  int Basker<Int, Entry, Exe_Space>::permute
  (
   ENTRY_1DARRAY vec,
   INT_1DARRAY   p, 
   Int n
   )
  {
    ENTRY_1DARRAY temp;
    MALLOC_ENTRY_1DARRAY(temp, n);
    init_value(temp, n, (Entry) 0.0);

    //Permute
    for(Int i = 0; i < n; i++)
      {
	temp(i) = vec(p(i));
	//temp(p(i)) = vec(i);
      }
    //Copy back
    for(Int i = 0; i < n; i++)
      {
	vec(i) = temp(i);
      }
   
    
    FREE_ENTRY_1DARRAY(temp);

    return 0;
  }
예제 #4
0
파일: SciCalc.cpp 프로젝트: GustavoMOG/ede
void SciCalc::factorial() {
  double lg, alpha;

  /* uses gamma functions to get result for non-integer values */

	alpha = value[top] + 1.0;
	if ((floor(alpha) == alpha)&&(alpha <= 0.0))
	{
		init_value(0);
		leddisplay->label("Error: -ve integer ");
		leddisplay->redraw();
	}
	else
	if (alpha > 32)
	 {
		lg = exp(gammaln(alpha));
    		value[top] = lg;
   		 set_display(value[top],NORM);
		ready = 1;
	}
	else
	if (alpha > 1.0)
	{
		int n = (int)truncf(alpha);
		lg = 1.0;
		for (int i = 1; i <n; i++) lg *= i;
		value[top] = lg;
		set_display(value[top],NORM);
		ready = 1;
	}
}
예제 #5
0
파일: ggsock.c 프로젝트: INNOAUS/gsl
static int
store_module_error (THREAD       *gsl_thread,
                    SOCK_CONTEXT *context,
                    RESULT_NODE  *error,
                    const char   *error_msg,
                          char   **error_text)
{
    GGCODE_TCB
        *gsl_tcb = gsl_thread-> tcb;
    VALUE
        value;

    if (error_msg)
      {
        if (! context)
            context = get_class_item (gsl_thread, SOCK_NAME);
        mem_free (context-> error_msg);
        context-> error_msg = memt_strdup (NULL, error_msg);

        if (error)
          {
            init_value (& value);
            assign_string (& value, context-> error_msg);
            if (! store_symbol_definition (& gsl_tcb-> scope_stack,
                                           gsl_tcb-> gsl-> ignorecase,
                                           error,
                                           &value,
                                           error_text))
                return -1;
          }
      }
    return 0;
}
예제 #6
0
attribute::attribute( AVT::VmbAPI::FeaturePtr feature )
    : feature_( feature )
    , type_( VmbFeatureDataUnknown )
{
    VmbErrorType status = feature_->GetName( name_ );
    if( status != VmbErrorSuccess )
    {
        COMMA_THROW( comma::exception, error_msg( "GetName() failed", status ));
    }

    status = feature_->GetDataType( type_ );
    if( status != VmbErrorSuccess )
    {
        COMMA_THROW( comma::exception, error_msg( "GetDataType() failed", status ));
    }

    status = feature_->GetDescription( description_ );
    if( status != VmbErrorSuccess )
    {
        COMMA_THROW( comma::exception, error_msg( "GetDescription() failed", status ));
    }

    init_value();
    init_allowed_values();
}
예제 #7
0
	/***************************************************************
	 * initEntityTable:
	 ***************************************************************/
static int   initEntityTable(	/* Return: num entities defined		*/
    void  *entTop		/* <r> top of paramList or qualList	*/
   ,struct cmd_struct  **addrTable /* <m> top of entity "lookup" table	*/
   )
   {
    int   i;
    int   icnt;
    int   sts;
    struct cduEntity  *e;

    if (!entTop)
        return(0);

		/*=====================================================
		 * Check size of entLookup[] list ...
		 *====================================================*/
    icnt = initLookupTable(entTop,addrTable);

    e = entTop;
    for (i=1 ; i<=icnt ; i++,e++)
       {
        sts = init_value(e->entA_value);
        e->entL_status =
                (e->entL_flags & ENT_M_DEFAULTED) ? CLI_STS_DEFAULTED : sts;
       }
    return(icnt);
   }
예제 #8
0
파일: main.c 프로젝트: DarmaN1/Wolf3D
int	main(int ac, char **av)
{
  t_data		data;
  /*  t_color		color[2];

  color[0].full = BLACK;
  color[1].full = RED;*/
  if (ac != 2)
    return (-1);
  data.ini = av[1];
  if (data.win == NULL)
    return  (-1);
  if ((data.wolf = init_map(data.ini)) == (t_wolf *)-1)
    return (EXIT_ON_ERROR);
  data.win = bunny_start(1200, 800, false, "Wolf3D");
  data.pix = bunny_new_pixelarray(1200, 800);
  data.color[0].argb[0] = 100;
  data.color[0].argb[1] = 100;
  data.color[0].argb[2] = 100;
  data.color[0].argb[3] = 255;
  init_value(data.wolf);
  bunny_set_loop_main_function((t_bunny_loop)main_loop);
  bunny_loop(data.win, 22, &data);
  bunny_free(data.wolf);
  bunny_delete_clipable(&data.pix->clipable);
  bunny_stop(data.win);
  return (0);
}
예제 #9
0
파일: SciCalc.cpp 프로젝트: GustavoMOG/ede
void SciCalc::cb_but_AC_i(Fl_Button*, void*) {
  init_value(0);
set_display(0.0,NORM);
currentbrkt = 0;
box_bracket->label("");
box_bracket->redraw();
}
예제 #10
0
  BASKER_INLINE
  int Basker<Int,Entry, Exe_Space>::permute_row(
				      BASKER_MATRIX &M,
				       INT_1DARRAY row)
  {

    if(M.nnz == 0)
      {
	return 0;
      }
    Int nnz = M.nnz;
    INT_1DARRAY temp_i;
    MALLOC_INT_1DARRAY(temp_i, nnz);
    init_value(temp_i, nnz, (Int)0);

    //permute
    for(Int k = 0; k < nnz; k++)
      {
        temp_i[k] = row[M.row_idx[k]];
      }
    //Copy back
    for(Int k = 0; k < nnz; k++)
      {
        M.row_idx[k] = temp_i[k];
      }
    FREE_INT_1DARRAY(temp_i);
    return 0;
  }//end permute_row(matrix,int)
예제 #11
0
double random(void)
{
   static double f=-1.0;
   if(f==-1.0)
     f=init_value();
   else
     f=ALPHA*f*(1.0-f);
   return f;
}
예제 #12
0
파일: ggsock.c 프로젝트: INNOAUS/gsl
static void
reply_readh_result (byte *body, char *error_msg)
{
    struct_smtsock_readh_reply
        *readh_reply;
    GGCODE_TCB
        *gsl_tcb = tcb-> gsl_thread-> tcb;
    VALUE
        value;
    char
        *error_text;

    /*  Pick up read value  */
    get_smtsock_readh_reply (body, & readh_reply);
    init_value (& value);
    if (readh_reply-> size > 0)
      {
        assign_string (& value, memt_alloc (NULL, readh_reply-> size + 1));
        memcpy (value. s, readh_reply-> data, readh_reply-> size);
        value. s [readh_reply-> size] = '\0';
      }
    /*  Store the value  */
    if (! store_symbol_definition (& gsl_tcb-> scope_stack,
                                   gsl_tcb-> gsl-> ignorecase,
                                   tcb-> buffer,
                                   &value,
                                   &error_text))
      {
        lsend_ggcode_call_error (& tcb-> gsl_thread-> queue-> qid, NULL,
                                 NULL, NULL, NULL, 0,
                                 NULL, 0,
                                 error_text);
        return;
      }
    destroy_value (& value);

    /*  Build return value  */
    assign_number (& tcb-> result-> value, readh_reply-> size);

    free_smtsock_readh_reply (& readh_reply);

    if (store_sock_error (tcb-> sock_handle,
                          tcb-> gsl_thread,
                          tcb-> context,
                          tcb-> error,
                          error_msg,
                          &error_text))
        lsend_ggcode_call_error (& tcb-> gsl_thread-> queue-> qid, NULL,
                                 NULL, NULL, NULL, 0,
                                 NULL, 0,
                                 error_text);
    else
        lsend_ggcode_call_ok (& tcb-> gsl_thread-> queue-> qid, NULL,
                              NULL, NULL, NULL, 0);
}
예제 #13
0
void				draw_triangle(t_env *e)
{
		int length = WIDTH - OFF;
		init_value(e);
		draw_polar(e->xn, e->yn, 180, length, e, RED);
		draw_polar(e->xn, e->yn, 60, length, e, GREEN);
		draw_polar(e->xn, e->yn, 300, length, e, BLUE);
		fdf_draw_line(e, XO, XO, YO, LY, YELLOW);
		e->mp = XN;
		e->xsym = e->mp;
		e->ysym = YN;
		draw_outer_circle(length, e);
}
예제 #14
0
  BASKER_FINLINE
  void Basker<Int, Entry,Exe_Space>::csymamd_order
  (
   BASKER_MATRIX &M,
   INT_1DARRAY p,
   INT_1DARRAY cmember
   )
  {    

    amd_flag = BASKER_TRUE;

    //Debug,
    #ifdef BASKER_DEBUG_ORDER_AMD
    printf("cmember: \n");
    for(Int i = 0; i < M.ncol; ++i)
      {
	printf("(%d, %d), ", i, cmember(i));
      }
    printf("\n"); 
    #endif
    
    //If doing  iluk, we will not want this.
    //See amd blk notes
    if(Options.incomplete == BASKER_TRUE)
      {
	for(Int i = 0; i < M.ncol; i++)
	  {
	    p(i) = i;
	  }
	//printf("Short csym \n");
	return;
      }



    INT_1DARRAY temp_p;
    BASKER_ASSERT(M.ncol > 0, "AMD perm not long enough");
    MALLOC_INT_1DARRAY(temp_p, M.ncol+1);
    init_value(temp_p, M.ncol+1, (Int) 0);
    
    my_amesos_csymamd(M.ncol, &(M.col_ptr(0)), &(M.row_idx(0)),
		     &(temp_p(0)), &(cmember(0)));


    for(Int i = 0; i < M.ncol; ++i)
      {
	p(temp_p(i)) = i;
      }


  }//end csymamd()
예제 #15
0
파일: ll.c 프로젝트: bigpussy/harib_os_src
void calc_value0(struct STR_VALUE *value, UCHAR **pexpr)
{
	UCHAR *expr = *pexpr, c, *t;
	int i, j, k;
	struct STR_VALUE tmp, tmp2;
	struct STR_SUBSECTION *subsect;
	c = *expr++;
	init_value(value);
	if (c <= 6) {
		/* 定数 */
		i = 0;
		if (c & 0x01)
			i--;
		value->min = get_id(c >> 1, &expr, i);
		goto fin;
	}
예제 #16
0
파일: oid.cpp 프로젝트: asir6/Colt
//=============[Oid:: operator = const Oid &oid ]==========================
// assignment to another oid object overloaded
//
// free the existing oid
// create a new one from the object passed in
// TODO: measure perf vs memory of no realloc in case where len >= oid.len
Oid& Oid::operator=( const Oid &oid)
{
  // protect against assignment from self
  if ( this == &oid)
      return *this;

  set_invalid();

  // check for zero len on source
  if ( oid.smival.value.oid.len == 0)
     return *this;

  const SmiLPOID srcOid = (SmiLPOID) &(oid.smival.value.oid);
  init_value(srcOid, oid.smival.value.oid.len);
  return *this;
}
예제 #17
0
파일: SciCalc.cpp 프로젝트: GustavoMOG/ede
void SciCalc::handle_number(double numb) {
  int first;
double sign;

	if (ready) init_value(top);

	if (numb == -1.0) 
	{
		if (dot) /* check whether we already have a dot */
			return;
		else 
		{
			dot = 1;
			set_display(value[top],DOT);
			return;
		}
	}

	if (emode) 
	{
		sign = copysign(1.0, (double)exponent);
		if (abs(exponent)*10 + numb > 999) 
		{ /* cycle if exponent has > 3 digits */
			first = (int)floor((double)abs(exponent)/100.0);
			exponent = abs(exponent) - 100*first;
			exponent *= (int)sign;
		}
		exponent = exponent*10 + (int) (sign*numb);
		value[top] = mantissa*pow(10.0, (double)exponent);
		set_display(mantissa, EXP);
	}
	else if (numb < base)
	{ /* both decimal and non decimal number entry */
		sign = copysign(1.0, value[top]);
		if (dot && behind < 9) 
		{
			behind++;
			diver = diver/(double)base;
			value[top] += sign*diver*numb;
		}
		else 
		if ((! dot) && (value[top] < 1.0e10))
			value[top] = (double)base*value[top] + sign*numb;

		set_display(value[top],(mode)behind);
	}
}
예제 #18
0
파일: parser.c 프로젝트: jonquach/raytracer
int		main(int ac, char **av)
{
  t_all		all;
  int		size;
  char		**tab;
  char		*file;

  if (ac > 1 && ac < 3)
    if ((file = read_it(av[1])) == NULL)
      return (put_error_int("THIS GAME SUCKS\n"));
  my_putstr(file);
  my_putstr("###################################################\n");
  if ((tab = my_str_to_wordtab(file, "\n")) == NULL)
    return (put_error_int("Error : STR_TO_WORDTAB failed\n"));
  if (init_value(&all, tab) == -1)
    return (put_error_int("Error : INIT_VALUE failed\n"));
}
void ParameterControl::ChartOptimization()
{
    std::vector<double> init_value(5, 1);
    init_value[3] = 0;
    
    std::string init_value_str = m_chart_init_value_le->text().toStdString();
    //    std::cout << init_value_str << std::endl;
    std::stringstream stream;
    stream << init_value_str;
    stream >> init_value[0] >> init_value[1] >> init_value[2] >> init_value[3] >> init_value[4] ;
    
    //    std::cout << init_value[0] <<" " << init_value[1] << " " << init_value[2] << " " << init_value[3] << " " << init_value[4] << std::endl;
    
    if(m_gl_viewer){
        m_gl_viewer-> SetChartInitValue(init_value);
        m_gl_viewer-> ChartOptimization();
    }
}
예제 #20
0
파일: SciCalc.cpp 프로젝트: GustavoMOG/ede
void SciCalc::handle_operator(Operator op) {
  int prevop, i, finished;

	switch (op)
	{
		case PLUS:
		case MINUS:
		case MULT:
		case DIV:
		case POW:
		case INVPOW:
			finished = 0;
			do 
			{
				if (top == startbrkt[currentbrkt]) finished = 1; /* is 1st operator */
				if (! finished) 
				{ /* compare priority of previous operators with current op */
					prevop = oper[top-1];
					if (priority[prevop] < priority[op])
						finished = 1;
					else 
					{ /* last op can be calculated */
						top--;
    					calc(top);
					}
				}
			} while (! finished);

			oper[top] = op;
			init_value(top+1);

			set_display(value[top-1],NORM);
			break;

		case EVAL:
			while (currentbrkt > 0) add_right_bracket();
			for (i = top; i > 0; i--) calc(i-1);
			top = 0;
			ready = 1;
			set_display(value[top],NORM);
			break;
	}
}
예제 #21
0
  BASKER_FINLINE
  void Basker<Int, Entry,Exe_Space>::csymamd_order
  (
   BASKER_MATRIX &M,
   INT_1DARRAY p,
   INT_1DARRAY cmember
   )
  {    

    amd_flag = BASKER_TRUE;

    //Debug,
    #ifdef BASKER_DEBUG_ORDER_AMD
    printf("cmember: \n");
    for(Int i = 0; i < M.ncol; ++i)
      {
	printf("(%d, %d), ", i, cmember(i));
      }
    printf("\n"); 
    #endif



    INT_1DARRAY temp_p;
    BASKER_ASSERT(M.ncol > 0, "AMD perm not long enough");
    MALLOC_INT_1DARRAY(temp_p, M.ncol+1);
    init_value(temp_p, M.ncol+1, (Int) 0);
    
    my_amesos_csymamd(M.ncol, &(M.col_ptr(0)), &(M.row_idx(0)),
		     &(temp_p(0)), &(cmember(0)));


    for(Int i = 0; i < M.ncol; ++i)
      {
	p(temp_p(i)) = i;
      }


  }//end csymamd()
예제 #22
0
	/****************************************************************
	 * init_value:
	 ****************************************************************/
static int   init_value(	/* Return: initial "processing" status	*/
    struct cduValue  *val	/* <m> value structure			*/
   )
   {
    int   sts;
    struct cduKeyword  *key;

    sts = 0;
    if (!val)
        return(0);

		/*-------------------------------------------------------
		 * Free any old values which might be attached ...
		 *------------------------------------------------------*/
    str_free1_dx(&val->val_dsc);
    val->valA_substring = 0;

		/*--------------------------------------------------------
		 * Init keywords ...
		 *-------------------------------------------------------*/
    if (key = val->valA_userType)
       {
        for ( ; key->keyA_name ; key++)
            key->keyL_status = init_value(key->keyA_value);
       }

		/*--------------------------------------------------------
		 * Check for default value.
		 *-------------------------------------------------------*/
    if (val->valA_default)
       {
        str_copy_dx(&val->val_dsc,val->valA_default);
        val->valA_substring = val->val_dsc.dscA_pointer;
        sts = CLI_STS_DEFAULTED;
       }
    return(sts);
   }
예제 #23
0
  BASKER_INLINE
  int Basker<Int, Entry, Exe_Space>::permute
  (
   ENTRY_1DARRAY vec,
   INT_1DARRAY   p, 
   Int n, //n = size(vec) //n > m 
   Int m,  //m = size(p) 
   Int start
   )
  {

    if(m > n)
      {
        printf("ERROR permtue \n");
        return BASKER_ERROR;
      }

    ENTRY_1DARRAY temp;
    MALLOC_ENTRY_1DARRAY(temp, n);
    init_value(temp, n, (Entry) 0.0);

    //Permute
    for(Int i = 0; i < n; i++)
      {
	temp(i) = vec(p(i));
	//temp(p(i)) = vec(i);
      }
    //Copy back
    for(Int i = 0; i < n; i++)
      {
	vec(i) = temp(i);
      }
   
    FREE_ENTRY_1DARRAY(temp);

    return 0;
  }
int		main(int ac, char **av)
{
  t_all		all;
  char		**tab;
  char		*file;

  if (ac == 2 || ac == 3)
    {
      if ((file = read_it(av[1])) == NULL)
	return (put_error_int("THIS GAME SUCKS\n"));
    }
  else
    return (put_error_int("RTFM ---> Usage : ./rt [XML]\n "));
  my_putstr(file);
  my_putstr("###################################################\n");
  if ((tab = my_str_to_wordtab(file, "\n")) == NULL)
    return (put_error_int("Error : STR_TO_WORDTAB failed\n"));
  if (init_value(&all, tab) == -1)
    return (put_error_int("Error : INIT_VALUE failed\n"));
  //all.my.k_color = 0;
  ///set_value(&all);
  init_raytracer(&all, av[2]);
  return (0);
}
예제 #25
0
파일: ggsock.c 프로젝트: INNOAUS/gsl
static VALUE * sock_handle_get_attr (void *item, const char *name, Bool ignorecase)
{

    SOCK_HANDLE_ITEM
        *socket = item;
    static VALUE
        value;

    if (! name)
        return NULL;

    init_value (& value);
        
    if (matches (name, "error"))
      {

        if (socket-> error_msg)
            assign_string (& value, socket-> error_msg);
        
      }

    return & value;
        
}
예제 #26
0
파일: ggsock.c 프로젝트: INNOAUS/gsl
static VALUE * sock_get_attr (void *item, const char *name, Bool ignorecase)
{

    SOCK_CONTEXT
        *context = item;
    static VALUE
        value;

    if (! name)
        return NULL;

    init_value (& value);
        
    if (matches (name, "error"))
      {

        if (context-> error_msg)
            assign_string (& value, context-> error_msg);
        
      }

    return & value;
        
}
예제 #27
0
파일: ggpcre.c 프로젝트: INNOAUS/gsl
static int
regexp_match (int argc, RESULT_NODE **argv, void *item, RESULT_NODE *result, THREAD *gsl_thread)
{
    RESULT_NODE *pattern = argc > 0 ? argv [0] : NULL;
    RESULT_NODE *subject = argc > 1 ? argv [1] : NULL;

    if (! pattern)
      {
        strcpy (object_error, "Missing argument: pattern");
        return -1;
      }
    if (pattern-> value. type == TYPE_UNDEFINED)
      {
        result-> culprit = pattern-> culprit;
        pattern-> culprit = NULL;
        return 0;
      }
    if (! subject)
      {
        strcpy (object_error, "Missing argument: subject");
        return -1;
      }
    if (subject-> value. type == TYPE_UNDEFINED)
      {
        result-> culprit = subject-> culprit;
        subject-> culprit = NULL;
        return 0;
      }

  {
    GGCODE_TCB
        *tcb = gsl_thread-> tcb;
    pcre
        *re;
    char
        *error;
    int 
        erroffset;
    int 
        *ovector;
    int
        oveccount,
        rc,
        i,
        start,
        len;
    VALUE
        value;

    re = pcre_compile (string_value (&pattern-> value),
                       0,
                       (const char **) &error,
                       &erroffset,
                       NULL);
    if (! re)
      {
        snprintf (object_error, LINE_MAX,
                  "Regular expression pattern error: %s\n%s\n%*c",
                  error,
                  pattern-> value. s,
                  erroffset + 1, '^');
        return -1;
      }

    rc = pcre_fullinfo (re,
                        NULL,
                        PCRE_INFO_CAPTURECOUNT,
                        &oveccount);
    oveccount = (oveccount + 1) * 3;
    ovector   = mem_alloc (oveccount * sizeof (int));

    string_value (&subject-> value);
    rc = pcre_exec (re,
                    NULL,
                    subject-> value. s,
                    (int) strlen (subject-> value. s),
                    0,
                    0,
                    ovector,
                    oveccount);

    (pcre_free) (re);

    if (rc == PCRE_ERROR_NOMATCH)
        rc = 0;
    else if (rc < 0)
      {
        snprintf (object_error, LINE_MAX,
                 "Regular expression matching error: %d", rc);
        mem_free (ovector);
        return -1;
      }
    else if (rc == 1)
        rc = -1;
    else
        rc -= 1;

    result-> value. type = TYPE_NUMBER;
    result-> value. n    = rc;

    i = 1;
    while (i < argc - 1)
      {
        if (argv [i + 1])
          {
            init_value (& value);
            if (i <= rc)
              {
                start = ovector [i * 2];
                len   = ovector [i * 2 + 1] - start;

                value. type = TYPE_STRING;
                value. s    = mem_alloc (len + 1);
                memcpy (value. s, subject-> value. s + start, len);
                value. s [len] = 0;
              }

            if (! store_symbol_definition (& tcb-> scope_stack,
                                           tcb-> gsl-> ignorecase,
                                           argv [i + 1],
                                           &value,
                                           &error))
              {
                strncpy (object_error, error, LINE_MAX);
                mem_free (value.s);
                mem_free (ovector);
                return -1;
              }
            destroy_value (& value);
          }
        i++;
      }

    mem_free (ovector);
  }

    return 0;  /*  Just in case  */
}
예제 #28
0
  BASKER_INLINE
  int Basker<Int, Entry, Exe_Space>::factor_notoken(Int option)
  {

    //printf("factor no token called \n");

    gn = A.ncol;
    gm = A.nrow;
    BASKER_MATRIX ATEMP;

    //Kokkos::Impl::Timer tza;
    if(Options.btf == BASKER_TRUE)
      {
	//JDB: We can change this for the new inteface
	gn = A.ncol;
	gm = A.nrow;
	ATEMP = A;
	A = BTF_A; 
      }
    //printf("Switch time: %f \n", tza.seconds());

   

    //Spit into Domain and Sep
    //----------------------Domain-------------------------//
    #ifdef BASKER_KOKKOS

    //====TIMER==
    #ifdef BASKER_TIME
    Kokkos::Impl::Timer       timer;
    #endif
    //===TIMER===

    typedef Kokkos::TeamPolicy<Exe_Space>        TeamPolicy;

    if(btf_tabs_offset != 0)
      {

	if(Options.verbose == BASKER_TRUE)
	  {
	    printf("Factoring Dom num_threads: %d \n",
		   num_threads);
	  }


	Int domain_restart = 0;
	kokkos_nfactor_domain <Int,Entry,Exe_Space>
	  domain_nfactor(this);
	Kokkos::parallel_for(TeamPolicy(num_threads,1), 
			     domain_nfactor);
	Kokkos::fence();
    

    //=====Check for error======
    while(true)
      {
	INT_1DARRAY thread_start;
	MALLOC_INT_1DARRAY(thread_start, num_threads+1);
	init_value(thread_start, num_threads+1, 
		   (Int) BASKER_MAX_IDX);
	int nt = nfactor_domain_error(thread_start);
	if((nt == BASKER_SUCCESS) ||
	   (nt == BASKER_ERROR) ||
	   (domain_restart > BASKER_RESTART))
	  {
	    break;
	  }
	else
	  {
	    domain_restart++;
	    if(Options.verbose == BASKER_TRUE)
	      {
		printf("restart \n");
	      }
	    kokkos_nfactor_domain_remalloc <Int, Entry, Exe_Space>
	      diag_nfactor_remalloc(this, thread_start);
	    Kokkos::parallel_for(TeamPolicy(num_threads,1),
				 diag_nfactor_remalloc);
	    Kokkos::fence();
	  }
      }//end while

    //====TIMER===
    #ifdef BASKER_TIME
    printf("Time DOMAIN: %f \n", timer.seconds());
    timer.reset();
    #endif
    //====TIMER====
    

    #else// else basker_kokkos
    #pragma omp parallel
    {


    }//end omp parallel
    #endif //end basker_kokkos

      }
    //-------------------End--Domian--------------------------//
    
    //printVec("domperm.csc", gpermi, A.nrow);
   
    //---------------------------Sep--------------------------//
   
    if(btf_tabs_offset != 0)
      {
    //for(Int l=1; l<=4; l++)
    for(Int l=1; l <= tree.nlvls; l++)
      {

	//#ifdef BASKER_OLD_BARRIER
	//Int lthreads = pow(2,l);
	//Int lnteams = num_threads/lthreads;
	//#else
	Int lthreads = 1;
	Int lnteams = num_threads/lthreads;
	//#endif

	Int sep_restart = 0;


	if(Options.verbose == BASKER_TRUE)
	  {
	    printf("Factoring Sep num_threads: %d %d \n",
		   lnteams, lthreads);
	  }

	#ifdef BASKER_KOKKOS
	Kokkos::Impl::Timer  timer_inner_sep;
	#ifdef BASKER_NO_LAMBDA

	//kokkos_nfactor_sep <Int, Entry, Exe_Space> 
	//sep_nfactor(this, l);

	kokkos_nfactor_sep2 <Int, Entry, Exe_Space>
	  sep_nfactor(this,l);
	
	Kokkos::parallel_for(TeamPolicy(lnteams,lthreads),
			     sep_nfactor);
	Kokkos::fence();

	//======Check for error=====
	while(true)
	  {
	    INT_1DARRAY thread_start;
	    MALLOC_INT_1DARRAY(thread_start, num_threads+1);
	    init_value(thread_start, num_threads+1,
		      (Int) BASKER_MAX_IDX);
	    int nt = nfactor_sep_error(thread_start);
	    if((nt == BASKER_SUCCESS)||
	       (nt == BASKER_ERROR) ||
	       (sep_restart > BASKER_RESTART))
	      {
		FREE_INT_1DARRAY(thread_start);
		break;
	      }
	    else
	      {
		sep_restart++;
		if (Options.verbose == BASKER_TRUE)
		  {
		    printf("restart \n");
		  }
		Kokkos::parallel_for(TeamPolicy(lnteams,lthreads),  sep_nfactor);
		Kokkos::fence();

	      }
	  }//end while-true


	#ifdef BASKER_TIME
	printf("Time INNERSEP: %d %f \n", 
	       l, timer_inner_sep.seconds());
	#endif
        #else //ELSE BASKER_NO_LAMBDA
	//Note: to be added
        #endif //end BASKER_NO_LAMBDA
	#else
	#pragma omp parallel
	{

	}//end omp parallel
	#endif
      }//end over each level

    #ifdef BASKER_TIME
    printf("Time SEP: %f \n", timer.seconds());
    #endif
      }
    
    //-------------------------End Sep----------------//


    //-------------------IF BTF-----------------------//
    if(Options.btf == BASKER_TRUE)
      {

	Int btf_restart = 0;

	if(Options.verbose == BASKER_TRUE)
	  {
	    printf("Factoring BLKs num_threads: %d \n",
		   num_threads);
	  }

	//=====Timer
	#ifdef BASKER_TIME
	Kokkos::Impl::Timer  timer_btf;
	#endif
	//====Timer
	
	//======Call diag factor====
	kokkos_nfactor_diag <Int, Entry, Exe_Space> 
	  diag_nfactor(this);
	Kokkos::parallel_for(TeamPolicy(num_threads,1),
			     diag_nfactor);
	Kokkos::fence();
	
	//=====Check for error======
	while(true)
	  {
	    INT_1DARRAY thread_start;
	    MALLOC_INT_1DARRAY(thread_start, num_threads+1);
	    init_value(thread_start, num_threads+1, 
		       (Int) BASKER_MAX_IDX);
	    int nt = nfactor_diag_error(thread_start);
	    //printf("RETURNED: %d \n", nt);
	    if((nt == BASKER_SUCCESS) || 
	       (nt == BASKER_ERROR) ||
	       (btf_restart > BASKER_RESTART))
	      {
		break;
	      }
	    else
	      {
		btf_restart++;
		if (Options.verbose == BASKER_TRUE)
		  {
		    printf("restart \n");
		  }
		kokkos_nfactor_diag_remalloc <Int, Entry, Exe_Space>
		  diag_nfactor_remalloc(this, thread_start);
		Kokkos::parallel_for(TeamPolicy(num_threads,1),
				     diag_nfactor_remalloc);
		Kokkos::fence();
	      }
	  }//end while

	//====TIMER
	#ifdef BASKER_TIME
	printf("Time BTF: %f \n", 
	       timer_btf.seconds());
	#endif
	//===TIMER

      }//end btf call

    Kokkos::Impl::Timer tzback;
     if(Options.btf == BASKER_TRUE)
      {
	A = ATEMP;
      }
     //printf("Switch back: %f \n",
     //	    tzback.seconds());
    
    return 0;
  }//end factor_notoken()
예제 #29
0
파일: SciCalc.cpp 프로젝트: GustavoMOG/ede
void SciCalc::cb_but_C_i(Fl_Button*, void*) {
  init_value(top); 
set_display(0.0,NORM);
}
예제 #30
0
파일: SciCalc.cpp 프로젝트: GustavoMOG/ede
SciCalc::SciCalc() {
  { win = new Fl_Double_Window(181, 262, "ecalc");
    win->user_data((void*)(this));
    { leddisplay = new Fl_Box(5, 3, 172, 24, "0 ");
      leddisplay->box(FL_DOWN_BOX);
      leddisplay->color((Fl_Color)207);
      leddisplay->labelfont(1);
      leddisplay->labelsize(16);
      leddisplay->labelcolor((Fl_Color)59);
      leddisplay->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
    } // Fl_Box* leddisplay
    { box_DEGRAD = new Fl_Box(24, 27, 35, 15, " ");
      box_DEGRAD->box(FL_ENGRAVED_BOX);
      box_DEGRAD->labelsize(9);
      box_DEGRAD->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
    } // Fl_Box* box_DEGRAD
    { box_bracket = new Fl_Box(59, 27, 65, 15);
      box_bracket->box(FL_ENGRAVED_BOX);
      box_bracket->labelsize(9);
      box_bracket->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
    } // Fl_Box* box_bracket
    { box_M = new Fl_Box(124, 27, 35, 15, "M");
      box_M->box(FL_ENGRAVED_BOX);
      box_M->labelsize(9);
      box_M->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
    } // Fl_Box* box_M
    { Fl_Group* o = new Fl_Group(46, 44, 93, 22);
      o->color((Fl_Color)46);
      { radio_2 = new Fl_Button(49, 48, 20, 15, "2");
        radio_2->type(102);
        radio_2->labelsize(10);
        radio_2->labelcolor((Fl_Color)1);
        radio_2->callback((Fl_Callback*)cb_radio_2);
      } // Fl_Button* radio_2
      { radio_8 = new Fl_Button(70, 48, 21, 15, "8");
        radio_8->type(102);
        radio_8->labelsize(10);
        radio_8->labelcolor((Fl_Color)1);
        radio_8->callback((Fl_Callback*)cb_radio_8);
      } // Fl_Button* radio_8
      { radio_10 = new Fl_Button(92, 48, 21, 15, "10");
        radio_10->type(102);
        radio_10->value(1);
        radio_10->labelsize(10);
        radio_10->labelcolor((Fl_Color)1);
        radio_10->callback((Fl_Callback*)cb_radio_10);
      } // Fl_Button* radio_10
      { radio_16 = new Fl_Button(114, 48, 21, 15, "16");
        radio_16->type(102);
        radio_16->labelsize(10);
        radio_16->labelcolor((Fl_Color)1);
        radio_16->callback((Fl_Callback*)cb_radio_16);
      } // Fl_Button* radio_16
      o->end();
    } // Fl_Group* o
    { Fl_Group* o = new Fl_Group(3, 163, 107, 94);
      o->box(FL_FLAT_BOX);
      o->color((Fl_Color)43);
      { but_7 = new Fl_Button(6, 167, 32, 20, "7");
        but_7->shortcut(0x37);
        but_7->labelfont(1);
        but_7->labelsize(16);
        but_7->callback((Fl_Callback*)cb_but_7);
      } // Fl_Button* but_7
      { but_8 = new Fl_Button(41, 167, 32, 20, "8");
        but_8->shortcut(0x38);
        but_8->labelfont(1);
        but_8->labelsize(16);
        but_8->callback((Fl_Callback*)cb_but_8);
      } // Fl_Button* but_8
      { but_9 = new Fl_Button(75, 167, 32, 20, "9");
        but_9->shortcut(0x39);
        but_9->labelfont(1);
        but_9->labelsize(16);
        but_9->callback((Fl_Callback*)cb_but_9);
      } // Fl_Button* but_9
      { but_4 = new Fl_Button(6, 189, 32, 20, "4");
        but_4->shortcut(0x34);
        but_4->labelfont(1);
        but_4->labelsize(16);
        but_4->callback((Fl_Callback*)cb_but_4);
      } // Fl_Button* but_4
      { but_5 = new Fl_Button(41, 189, 32, 20, "5");
        but_5->shortcut(0x35);
        but_5->labelfont(1);
        but_5->labelsize(16);
        but_5->callback((Fl_Callback*)cb_but_5);
      } // Fl_Button* but_5
      { but_6 = new Fl_Button(75, 189, 32, 20, "6");
        but_6->shortcut(0x36);
        but_6->labelfont(1);
        but_6->labelsize(16);
        but_6->callback((Fl_Callback*)cb_but_6);
      } // Fl_Button* but_6
      { but_1 = new Fl_Button(6, 211, 32, 20, "1");
        but_1->shortcut(0x31);
        but_1->labelfont(1);
        but_1->labelsize(16);
        but_1->callback((Fl_Callback*)cb_but_1);
      } // Fl_Button* but_1
      { but_2 = new Fl_Button(41, 211, 32, 20, "2");
        but_2->shortcut(0x32);
        but_2->labelfont(1);
        but_2->labelsize(16);
        but_2->callback((Fl_Callback*)cb_but_2);
      } // Fl_Button* but_2
      { but_3 = new Fl_Button(75, 211, 32, 20, "3");
        but_3->shortcut(0x33);
        but_3->labelfont(1);
        but_3->labelsize(16);
        but_3->callback((Fl_Callback*)cb_but_3);
      } // Fl_Button* but_3
      { but_0 = new Fl_Button(6, 233, 32, 20, "0");
        but_0->shortcut(0x30);
        but_0->labelfont(1);
        but_0->labelsize(16);
        but_0->callback((Fl_Callback*)cb_but_0);
      } // Fl_Button* but_0
      { but_dot = new Fl_Button(41, 233, 32, 20, ".");
        but_dot->shortcut(0x2e);
        but_dot->labelfont(1);
        but_dot->labelsize(16);
        but_dot->callback((Fl_Callback*)cb_but_dot);
      } // Fl_Button* but_dot
      { but_sign = new Fl_Button(75, 233, 32, 20, "+/-");
        but_sign->labelfont(1);
        but_sign->labelsize(16);
        but_sign->callback((Fl_Callback*)cb_but_sign);
      } // Fl_Button* but_sign
      o->end();
    } // Fl_Group* o
    { but_C = new Fl_Button(112, 167, 31, 20, "C");
      but_C->labelfont(1);
      but_C->labelsize(16);
      but_C->callback((Fl_Callback*)cb_but_C);
    } // Fl_Button* but_C
    { but_AC = new Fl_Button(146, 167, 30, 20, "AC");
      but_AC->labelfont(1);
      but_AC->labelsize(16);
      but_AC->callback((Fl_Callback*)cb_but_AC);
    } // Fl_Button* but_AC
    { but_X = new Fl_Button(112, 189, 31, 20, "x");
      but_X->shortcut(0x2a);
      but_X->labelfont(1);
      but_X->labelsize(16);
      but_X->callback((Fl_Callback*)cb_but_X);
    } // Fl_Button* but_X
    { but_div = new Fl_Button(146, 189, 30, 20, "/");
      but_div->shortcut(0x2f);
      but_div->labelfont(1);
      but_div->labelsize(16);
      but_div->callback((Fl_Callback*)cb_but_div);
    } // Fl_Button* but_div
    { but_plus = new Fl_Button(112, 211, 31, 20, "+");
      but_plus->shortcut(0x2b);
      but_plus->labelfont(1);
      but_plus->labelsize(16);
      but_plus->callback((Fl_Callback*)cb_but_plus);
    } // Fl_Button* but_plus
    { but_minus = new Fl_Button(146, 211, 30, 20, "-");
      but_minus->shortcut(0x2d);
      but_minus->labelfont(1);
      but_minus->labelsize(16);
      but_minus->callback((Fl_Callback*)cb_but_minus);
    } // Fl_Button* but_minus
    { but_pi = new Fl_Button(112, 233, 31, 20, "e/p");
      but_pi->labelfont(12);
      but_pi->labelsize(17);
      but_pi->callback((Fl_Callback*)cb_but_pi);
    } // Fl_Button* but_pi
    { but_eval = new Fl_Button(146, 233, 30, 20, "=");
      but_eval->shortcut(0x3d);
      but_eval->labelfont(1);
      but_eval->labelsize(16);
      but_eval->callback((Fl_Callback*)cb_but_eval);
    } // Fl_Button* but_eval
    { but_eval_hidden = new Fl_Button(147, 253, 6, 7);
      but_eval_hidden->box(FL_NO_BOX);
      but_eval_hidden->shortcut(0xff0d);
      but_eval_hidden->labelfont(1);
      but_eval_hidden->labelsize(16);
      but_eval_hidden->callback((Fl_Callback*)cb_but_eval_hidden);
    } // Fl_Button* but_eval_hidden
    { but_eval_hidden2 = new Fl_Button(157, 263, 6, 7);
      but_eval_hidden2->box(FL_NO_BOX);
      but_eval_hidden2->shortcut(0xff8d);
      but_eval_hidden2->labelfont(1);
      but_eval_hidden2->labelsize(16);
      but_eval_hidden2->callback((Fl_Callback*)cb_but_eval_hidden2);
    } // Fl_Button* but_eval_hidden2
    { but_sqrt = new Fl_Button(6, 70, 32, 21, "sqrt");
      but_sqrt->labelsize(11);
      but_sqrt->labelcolor((Fl_Color)4);
      but_sqrt->callback((Fl_Callback*)cb_but_sqrt);
    } // Fl_Button* but_sqrt
    { but_pow = new Fl_Button(41, 70, 32, 21, "x^y");
      but_pow->labelsize(11);
      but_pow->labelcolor((Fl_Color)4);
      but_pow->callback((Fl_Callback*)cb_but_pow);
    } // Fl_Button* but_pow
    { but_sin = new Fl_Button(76, 70, 31, 21, "sin");
      but_sin->labelsize(11);
      but_sin->labelcolor((Fl_Color)4);
      but_sin->callback((Fl_Callback*)cb_but_sin);
    } // Fl_Button* but_sin
    { but_cos = new Fl_Button(110, 70, 31, 21, "cos");
      but_cos->labelsize(11);
      but_cos->labelcolor((Fl_Color)4);
      but_cos->callback((Fl_Callback*)cb_but_cos);
    } // Fl_Button* but_cos
    { but_tan = new Fl_Button(144, 70, 30, 21, "tan");
      but_tan->labelsize(11);
      but_tan->labelcolor((Fl_Color)4);
      but_tan->callback((Fl_Callback*)cb_but_tan);
    } // Fl_Button* but_tan
    { but_log = new Fl_Button(6, 93, 32, 21, "log");
      but_log->labelsize(11);
      but_log->labelcolor((Fl_Color)4);
      but_log->callback((Fl_Callback*)cb_but_log);
    } // Fl_Button* but_log
    { but_ln = new Fl_Button(41, 93, 32, 21, "ln");
      but_ln->labelsize(11);
      but_ln->labelcolor((Fl_Color)4);
      but_ln->callback((Fl_Callback*)cb_but_ln);
    } // Fl_Button* but_ln
    { but_int = new Fl_Button(76, 93, 31, 21, "int");
      but_int->labelsize(11);
      but_int->labelcolor((Fl_Color)4);
      but_int->callback((Fl_Callback*)cb_but_int);
    } // Fl_Button* but_int
    { but_dr = new Fl_Button(110, 93, 31, 21, "d->r");
      but_dr->labelsize(10);
      but_dr->labelcolor((Fl_Color)4);
      but_dr->callback((Fl_Callback*)cb_but_dr);
    } // Fl_Button* but_dr
    { but_drg = new Fl_Button(144, 93, 30, 21, "d-r-g");
      but_drg->labelsize(9);
      but_drg->callback((Fl_Callback*)cb_but_drg);
    } // Fl_Button* but_drg
    { but_leftbr = new Fl_Button(6, 116, 32, 21, "[");
      but_leftbr->shortcut(0x28);
      but_leftbr->labelsize(11);
      but_leftbr->callback((Fl_Callback*)cb_but_leftbr);
    } // Fl_Button* but_leftbr
    { but_rightbr = new Fl_Button(41, 116, 32, 21, "]");
      but_rightbr->shortcut(0x29);
      but_rightbr->labelsize(11);
      but_rightbr->callback((Fl_Callback*)cb_but_rightbr);
    } // Fl_Button* but_rightbr
    { but_exch = new Fl_Button(76, 116, 31, 21, "exch");
      but_exch->labelsize(11);
      but_exch->callback((Fl_Callback*)cb_but_exch);
    } // Fl_Button* but_exch
    { but_invx = new Fl_Button(110, 116, 31, 21, "1/x");
      but_invx->labelsize(11);
      but_invx->callback((Fl_Callback*)cb_but_invx);
    } // Fl_Button* but_invx
    { but_fact = new Fl_Button(144, 116, 30, 21, "x!");
      but_fact->labelsize(11);
      but_fact->callback((Fl_Callback*)cb_but_fact);
    } // Fl_Button* but_fact
    { but_Mplus = new Fl_Button(6, 139, 32, 21, "M+");
      but_Mplus->color((Fl_Color)93);
      but_Mplus->labelcolor((Fl_Color)4);
      but_Mplus->callback((Fl_Callback*)cb_but_Mplus);
    } // Fl_Button* but_Mplus
    { but_Mmult = new Fl_Button(41, 139, 32, 21, "M*");
      but_Mmult->color((Fl_Color)93);
      but_Mmult->labelcolor((Fl_Color)4);
      but_Mmult->callback((Fl_Callback*)cb_but_Mmult);
    } // Fl_Button* but_Mmult
    { but_Mclear = new Fl_Button(76, 139, 31, 21, "MC");
      but_Mclear->color((Fl_Color)93);
      but_Mclear->labelcolor((Fl_Color)4);
      but_Mclear->callback((Fl_Callback*)cb_but_Mclear);
    } // Fl_Button* but_Mclear
    { but_Mst = new Fl_Button(110, 139, 31, 21, "Mst");
      but_Mst->color((Fl_Color)93);
      but_Mst->callback((Fl_Callback*)cb_but_Mst);
    } // Fl_Button* but_Mst
    { but_Mrc = new Fl_Button(144, 139, 30, 21, "Mrc");
      but_Mrc->color((Fl_Color)93);
      but_Mrc->callback((Fl_Callback*)cb_but_Mrc);
    } // Fl_Button* but_Mrc
    { check_inv = new Fl_Button(6, 44, 32, 21, "inv");
      check_inv->type(1);
      check_inv->labelsize(11);
      check_inv->labelcolor((Fl_Color)4);
      check_inv->callback((Fl_Callback*)cb_check_inv);
    } // Fl_Button* check_inv
    { but_quit = new Fl_Button(145, 44, 29, 21, "Exit");
      but_quit->labelfont(1);
      but_quit->labelcolor((Fl_Color)33);
      but_quit->callback((Fl_Callback*)cb_but_quit);
    } // Fl_Button* but_quit
    win->end();
  } // Fl_Double_Window* win
  init_value(0);
	drgmode = 1;
	base = 10;
	currentbrkt = 0;
	startbrkt[0] = 0;

	set_memdisp();
	set_brktdisp();
	radio_10->value(1);
	set_drgdisp();
	set_display(0.0,NONE);
}