Exemplo n.º 1
0
/*-------------------------------------------------------------*/
void AzDmat::prod(const AzDmat *m0, const AzDmat *m1, bool is_m0_tran, bool is_m1_tran)
{
  const char *eyec = "AzDmat::prod"; 
  if (is_m1_tran) {
    throw new AzException(eyec, "No support for the transpose of the second matrix"); 
  }
  if (is_m0_tran) {
    reform(m0->colNum(), m1->colNum()); 
    for (int col = 0; col < m1->colNum(); ++col) {
      AzDvect *myv = col_u(col); 
      const AzDvect *v1 = m1->col(col); 
      for (int row = 0; row < rowNum(); ++row) {
        double val = m0->col(col)->innerProduct(v1); 
        myv->set(row, val); 
      }
    }
  }
  else {
    reform(m0->rowNum(), m1->colNum()); 
    for (int col = 0; col < m1->colNum(); ++col) {
      AzDvect *myv = col_u(col); 
      const AzDvect *v1 = m1->col(col); 
      for (int row1 = 0; row1 < v1->rowNum(); ++row1) {
        myv->add(m0->col(row1), v1->get(row1)); 
      }
    }      
  }
}
Exemplo n.º 2
0
 qt_dbtablemenu_impl :: qt_dbtablemenu_impl(qt_dbtablemenu *parent, qt_dbtableview *view, qt_dbdialog *dialog)
 : _parent(parent), _view(view), _dialog(dialog), _oldCount(0) {
   if (!_parent || !_view || !_dialog) return;
   
   _actions.push_back(new(nothrow) QAction(qt_dbtablemenu::tr("Add"), 0));
   _actions.back()->setVisible(true);
   _acts[_actions.back()] = &qt_dbtablemenu_impl :: _add;
   _actions.push_back(new(nothrow) QAction(qt_dbtablemenu::tr("Clone"), 0));
   _actions.back()->setVisible(false);
   _acts[_actions.back()] = &qt_dbtablemenu_impl :: _clone;
   _actions.push_back(new(nothrow) QAction(qt_dbtablemenu::tr("Edit"), 0));
   _actions.back()->setVisible(false);
   _acts[_actions.back()] = &qt_dbtablemenu_impl :: _edit;
   _actions.push_back(new(nothrow) QAction(qt_dbtablemenu::tr("Del"), 0));
   _actions.back()->setVisible(false);
   _acts[_actions.back()] = &qt_dbtablemenu_impl :: _del;
   
   foreach(QAction * action, _actions)
       QObject::connect(action, SIGNAL(triggered()), _parent, SLOT(trigger()));
       
   _view->setContextMenuPolicy(Qt::ActionsContextMenu);
   _view->addActions(_actions);
   //QObject::connect(_view, SIGNAL(clicked(const QModelIndex&)), this, SLOT(_click(const QModelIndex&)));
   QObject::connect(_view, SIGNAL(doubleClicked(const QModelIndex&)), _dialog, SLOT(edit(const QModelIndex&)));
   //QObject::connect(_dialog, SIGNAL(changed()), _view, SLOT(select()));
   QObject::connect(_dialog, SIGNAL(changed()), _parent, SLOT(reform()));
   reform();
 }
Exemplo n.º 3
0
 void xxT(const AzDmat *m) {
   reform(m->rowNum(), m->rowNum()); 
   int cx;
   for (cx = 0; cx < m->colNum(); ++cx) {
     add_xxT(m->col(cx)); 
   }
 }
Exemplo n.º 4
0
/*-------------------------------------------------------------*/
void AzDmatc::set(const AzSmat *m) 
{
  const char *eyec = "AzDmatc::set(smat)"; 
  AzX::throw_if((m==NULL), eyec, "null input"); 
  reform(m->rowNum(), m->colNum()); 
  for (int col = 0; col < col_num; ++col) {
    AZ_MTX_FLOAT *dst = elm+(AZint8)row_num*(AZint8)col; 
    int num; const AZI_VECT_ELM *src = m->rawcol(col, &num); 
    for (int ix = 0; ix < num; ++ix) dst[src[ix].no] = src[ix].val;  
  }
}
Exemplo n.º 5
0
void get_string(const char *cmd, char *data, int len) {
    char buffer[1000];
    char *loc1,*loc2;
    modem_cmd(cmd,buffer,sizeof(buffer)-1,100,0);
    loc1 = strchr(buffer,'\n');
    if (loc1 != NULL) {
        loc1++;
        loc1 = strchr(loc1,'\n');
    }
    if (loc1 != NULL) {
        loc1++;
        loc2 = strchr(loc1,'\r');
        loc2[0] = '\0';
        strncpy(data,loc1,len-1);
    } else {
        message(MSG_WARNING,"Could not parse string from output! (received: \"%s\")",reform(buffer,1));
        data[0]='\0';
    }
    message(MSG_DEBUG,"Parsed string (len=%d): %s", len, reform(data,1));
}
Exemplo n.º 6
0
 /*---  transpose(x) times x  ---*/
 void xTx(const AzDmat *m) {
   reform(m->colNum(), m->colNum()); 
   int cx, cx1;
   for (cx = 0; cx < m->colNum(); ++cx) {
     const AzDvect *v = m->col(cx); 
     for (cx1 = cx; cx1 < m->colNum(); ++cx1) {
       double val = v->innerProduct(m->col(cx1)); 
       set(cx, cx1, val); 
       set(cx1, cx, val); 
     }
   }
 }
Exemplo n.º 7
0
/* WARNING: not tested */
void AzDvect::set(const AzSvect *v_inp) 
{
  const char *eyec = "AzDvect::set(Svect)"; 
  if (v_inp == NULL) {
    throw new AzException(eyec, "null input"); 
  }
  reform(v_inp->row_num); 
  if (num > 0) {
    int ix; 
    for (ix = 0; ix < v_inp->elm_num; ++ix) {
      elm[v_inp->elm[ix].no] = v_inp->elm[ix].val; 
    } 
  }
}
Exemplo n.º 8
0
int get_battery(int *mode, int *charge) {
    char buffer[1000], *pos;
    modem_cmd("AT+CBC\r\n",buffer,sizeof(buffer)-1,50,0);

    pos = strstr(buffer, "+CBC:");
    if (pos == NULL) {
        message(MSG_WARNING,"Could not read battery status! (received: \"%s\")",reform(buffer,1));
        *mode = -1;
        *charge = -1;
    } else {
        sscanf(pos,"+CBC: %d, %d",mode,charge);
    }
    return *charge;
}
Exemplo n.º 9
0
int get_signal(int *rssi, int *ber) {
    char buffer[1000], *pos;
    modem_cmd("AT+CSQ\r\n",buffer,sizeof(buffer)-1,50,0);

    pos = strstr(buffer, "+CSQ:");
    if (pos == NULL) {
        message(MSG_WARNING,"Could not read signal quality! (received: \"%s\")",reform(buffer,1));
        *rssi = -1;
        *ber = -1;
    } else {
        sscanf(pos,"+CSQ: %d, %d",rssi,ber);
    }

    return *rssi;
}
Exemplo n.º 10
0
/*-------------------------------------------------------------*/
void AzDmat::transpose_from(const AzSmat *m_inp)
{
  reform(m_inp->colNum(), m_inp->rowNum()); 
  int cx; 
  for (cx = 0; cx < m_inp->colNum(); ++cx) {
    const AzSvect *v_inp = m_inp->col(cx); 
    AzCursor cursor; 
    for ( ; ; ) {
      double val; 
      int rx = v_inp->next(cursor, val); 
      if (rx < 0) break; 
      set(cx, rx, val); 
    }
  }
}
Exemplo n.º 11
0
/*-------------------------------------------------------------*/
void AzDvect::set(const AzReadOnlyVector *v_inp) 
{
  const char *eyec = "AzDvect::set(AzReadOnlyVector)"; 
  if (v_inp == NULL) {
    throw new AzException(eyec, "null input"); 
  }
  reform(v_inp->rowNum()); 
  if (num > 0) {
    AzCursor cursor; 
    for ( ; ; ) {
      double val; 
      int ex = v_inp->next(cursor, val); 
      if (ex < 0) break; 
      elm[ex] = val;  
    } 
  }
}
Exemplo n.º 12
0
/*-------------------------------------------------------------*/
int AzDmat::set(const AzDmat *inp, const int *cols, int cnum,  /* new2old */
                bool do_zero_negaindex) 
{
  if (row_num != inp->row_num || col_num != cnum) {
    reform(inp->row_num, cnum); 
  }
  int negaindex = 0; 
  int my_col; 
  for (my_col = 0; my_col < cnum; ++my_col) {
    int col = cols[my_col]; 
    if (col < 0 && do_zero_negaindex) {
      column[my_col]->zeroOut();     
      ++negaindex; 
      continue; 
    }   
    if (col < 0 || col >= inp->col_num) {
      throw new AzException("AzDmat::set(inp,cols,cnum)", "invalid col#"); 
    }
    column[my_col]->set(inp->column[col]); 
  }
  return negaindex; 
}
Exemplo n.º 13
0
void GLWidget::blueRobotsMenuTriggered(QAction *act)
{
    reform(0,act->text());
}
Exemplo n.º 14
0
void GLWidget::yellowRobotsMenuTriggered(QAction *act)
{
    reform(1,act->text());
}
Exemplo n.º 15
0
Arquivo: CW.C Projeto: kytulendu/TW
int main( int argc, char *argv[] ) {
	/* (x,y) position of edit window. x column, y line -> (0,0) at upper left on screen */
	unsigned int xCursorPos = 0;
	unsigned int yCursorPos = 0;

	unsigned int curmenu = 0x1100;
	int i;

	cwsetup( argc, argv );

	writestatus( 0 );
	writetab( );

	splashscreen( );

	/* Main program loop */
	do {
		dispstrhgc( "   ", wind.col, 2, NORMALATTR );
		i = pulled_down_menu( &curmenu, &xCursorPos, &yCursorPos );
		if ( filename[0] != '\0' ) {
			switch ( i ) {
			case RETKEY:
				keymain = menu_to_key( curmenu );
				break;

			case ESCKEY:
				waitkbd( wind.col + xCursorPos, wind.row + yCursorPos );		/* Show blinking cursor */
				keymain = readkbd( );		/* If keypressed Get it */
				break;

			default:
				keymain = i;
				break;
			}

			while ( keymain != ESCKEY ) {
				if ( ( keymain & 0xff ) >= 32 ) {
					keymain = changekey( keymain );
					if ( insertmode ) {
						if ( !insert_char( keymain, &xCursorPos, &yCursorPos ) ) {
							linetoolong( );
						}
					} else {
						if ( !ovrwrite_char( keymain, &xCursorPos, &yCursorPos ) ) {
							linetoolong( );
						}
					}
					refreshline( xCursorPos, yCursorPos );
				} else {	/*  Function Key  */
					switch ( keymain ) {
					case PGUPKEY:
					case CNTRL_R:
						page_up( );
						break;

					case PGDNKEY:
					case CNTRL_C:
						page_down( );
						break;

					case UPKEY:
					case CNTRL_E:
						cursor_up( );
						break;

					case DNKEY:
					case CNTRL_X:
						cursor_down( yCursorPos );
						break;

					case LEKEY:
					case CNTRL_S:
						cursor_left( &xCursorPos );
						break;

					case 0x2301:
						gobeginblk( &xCursorPos );
						break;

					case 0x2401:
						goendblk( &xCursorPos );
						break;

					case RIKEY:
					case CNTRL_D:
						cursor_right( &xCursorPos, yCursorPos );
						break;

					case CNTRL_W:
						scroll_up( );
						break;

					case CNTRL_Z:
						scroll_down( );
						break;

					case CHOMEKEY:
						top_of_page( );
						break;

					case CPGUPKEY:
						topfile( &xCursorPos );
						break;

					case CENDKEY:
						bottom_of_page( );
						break;

					case CPGDNKEY:
						endfile( &xCursorPos );
						break;

					case DELKEY:
					case CNTRL_G:
						delete_char( xCursorPos );
						refreshline( xCursorPos, yCursorPos );
						changeflag = YES;
						break;

					case CNTRL_T:
						delete_word( xCursorPos );
						refreshline( xCursorPos, yCursorPos );
						changeflag = YES;
						break;

					case CNTRL_Y:
						delete_line( );
						changeflag = YES;
						break;

					case CNTRL_M:
					case RETKEY:
						if ( insertmode == NO ) {
							returnkey( &xCursorPos, yCursorPos );
						} else {
							ret_with_ins( &xCursorPos, yCursorPos );
							changeflag = YES;
						}
						break;

					case BSKEY:
					case CNTRL_H:
						backspace( &xCursorPos );
						yCursorPos = findrow( );
						refreshline( 0, yCursorPos );
						changeflag = YES;
						break;

					case INSKEY:
					case CNTRL_V:
						insertmode = !insertmode;
						writeinsmode( );
						break;

					case CNTRL_N:
						insert_ret( &xCursorPos );
						break;

					case F10KEY:
						thaimode = !thaimode;
						writelanguage( );
						break;

					case F1KEY:
						fontused = 0x00;
						writeattr( );
						break;

					case F2KEY:
						fontused = fontused | ITALICATTR;
						writeattr( );
						break;

					case F3KEY:
						fontused = fontused | ONELINEATTR;
						fontused = fontused & 0x7f;
						writeattr( );
						break;

					case F4KEY:
						fontused = fontused | TWOLINEATTR;
						fontused = fontused & 0xfe;
						writeattr( );
						break;

					case F5KEY:
						fontused = fontused | BOLDATTR;
						writeattr( );
						break;

					case F6KEY:
						fontused = fontused | ENLARGEATTR;
						writeattr( );
						break;

					case F7KEY:
						fontused = fontused | SUPERATTR;
						if ( ( fontused & SUBATTR ) == SUBATTR ) {
							fontused = fontused ^ SUBATTR;
						}
						writeattr( );
						break;

					case F8KEY:
						fontused = fontused | SUBATTR;
						if ( ( fontused & SUPERATTR ) == SUPERATTR ) {
							fontused = fontused ^ SUPERATTR;
						}
						writeattr( );
						break;

					case F9KEY:
						manualwrap( &xCursorPos, &yCursorPos );
						break;

					case ALTM:
						editmacro( );
						break;

					case TABKEY:
					case CNTRL_I:
						movetotab( &xCursorPos, yCursorPos );
						break;

					case CNTRL_K:
						blockcommand( &xCursorPos );
						break;

					case 0x1401:
						blkcmd( 'p', &xCursorPos );
						break;
					case 0x6101:
						blkcmd( 'b', &xCursorPos );
						break;
					case 0x6201:
						blkcmd( 'k', &xCursorPos );
						break;
					case 0x6301:
						blkcmd( 'c', &xCursorPos );
						break;
					case 0x6401:
						blkcmd( 'y', &xCursorPos );
						break;
					case 0x6501:
						blkcmd( 'v', &xCursorPos );
						break;
					case 0x6601:
						blkcmd( 'r', &xCursorPos );
						break;
					case 0x6701:
						blkcmd( 'w', &xCursorPos );
						break;
					case 0x6801:
						blkcmd( 'h', &xCursorPos );
						break;

					case CNTRL_O:
						onscreen( xCursorPos, yCursorPos );
						break;

					case 0x7101:
						doonscrn( 'l', xCursorPos, yCursorPos );
						break;
					case 0x7201:
						doonscrn( 'r', xCursorPos, yCursorPos );
						break;
					case 0x7301:
						doonscrn( 'i', xCursorPos, yCursorPos );
						break;
					case 0x7401:
						doonscrn( 'n', xCursorPos, yCursorPos );
						break;
					case 0x7501:
						doonscrn( 'c', xCursorPos, yCursorPos );
						break;
					case 0x7601:
						doonscrn( 'p', xCursorPos, yCursorPos );
						break;
					case 0x7701:
						doonscrn( 'x', xCursorPos, yCursorPos );
						break;

					case CNTRL_Q:
						quick( &xCursorPos, &yCursorPos );
						break;

					case 0x3501:
						deltoendline( xCursorPos, yCursorPos );
						break;

					case 0x8111:
						inscntrl( CNTRL_W, xCursorPos, yCursorPos );
						break;
					case 0x8211:
						inscntrl( CNTRL_S, xCursorPos, yCursorPos );
						break;
					case 0x8311:
						inscntrl( CNTRL_R, xCursorPos, yCursorPos );
						break;
					case 0x8411:
						inscntrl( CNTRL_B, xCursorPos, yCursorPos );
						break;
					case 0x8511:
						inscntrl( CNTRL_E, xCursorPos, yCursorPos );
						break;
					case 0x8611:
						inscntrl( CNTRL_T, xCursorPos, yCursorPos );
						break;
					case 0x8711:
						inscntrl( CNTRL_V, xCursorPos, yCursorPos );
						break;

					case CNTRL_P:
						printcntrl( xCursorPos, yCursorPos );
						break;

					case HOMEKEY:
						home( &xCursorPos );
						break;

					case ENDKEY:
						endline( &xCursorPos );
						break;

					case CLEKEY:
					case CNTRL_A:
						backword( &xCursorPos );
						break;

					case CRIKEY:
					case CNTRL_F:
						nextword( &xCursorPos, yCursorPos );
						break;

					case CNTRL_L:
						if ( source[0] != '\0' ) {
							if ( replaceflag == NO ) {
								if ( searchfwd( &xCursorPos, &yCursorPos ) == NO ) {
									wordnotfound( );
								}
							} else {
								if ( searchreplace( &xCursorPos, &yCursorPos ) == NO ) {
									wordnotfound( );
								}
							}
						}
						break;

					case CNTRL_B:
						reform( );
						break;

					case ALTP:
						gotopage( );
						break;

					case CNTRL_J:
					case ALTL:
						gotoline( );
						break;

					case 0x5101:
						searching( &xCursorPos, &yCursorPos );
						break;

					case 0x5201:
						replacing( &xCursorPos, &yCursorPos );
						break;

					case 0x8501:
						loadtoline( curline->text );
						refreshline( 0, yCursorPos );
						break;

					case CF1KEY:
						insertmacro( &macro[0][0], &xCursorPos, &yCursorPos );
						break;
					case CF2KEY:
						insertmacro( &macro[1][0], &xCursorPos, &yCursorPos );
						break;
					case CF3KEY:
						insertmacro( &macro[2][0], &xCursorPos, &yCursorPos );
						break;
					case CF4KEY:
						insertmacro( &macro[3][0], &xCursorPos, &yCursorPos );
						break;
					case CF5KEY:
						insertmacro( &macro[4][0], &xCursorPos, &yCursorPos );
						break;
					case CF6KEY:
						insertmacro( &macro[5][0], &xCursorPos, &yCursorPos );
						break;
					case CF7KEY:
						insertmacro( &macro[6][0], &xCursorPos, &yCursorPos );
						break;
					case CF8KEY:
						insertmacro( &macro[7][0], &xCursorPos, &yCursorPos );
						break;
					case CF9KEY:
						insertmacro( &macro[8][0], &xCursorPos, &yCursorPos );
						break;
					case CF10KEY:
						insertmacro( &macro[9][0], &xCursorPos, &yCursorPos );
						break;

					case AF2KEY:
						inscntrl( ITALICCODE, xCursorPos, yCursorPos );
						break;
					case AF3KEY:
						inscntrl( ONELINECODE, xCursorPos, yCursorPos );
						break;
					case AF4KEY:
						inscntrl( TWOLINECODE, xCursorPos, yCursorPos );
						break;
					case AF5KEY:
						inscntrl( BOLDCODE, xCursorPos, yCursorPos );
						break;
					case AF6KEY:
						inscntrl( ENLARGECODE, xCursorPos, yCursorPos );
						break;
					case AF7KEY:
						inscntrl( SUPERCODE, xCursorPos, yCursorPos );
						break;
					case AF8KEY:
						inscntrl( SUBCODE, xCursorPos, yCursorPos );
						break;

#ifdef WANT_TO_USE_GRAPH
					case ALTG:
						insertgraph( );
						break;
					case ALTD:
						deletegraph( );
						break;
#endif

					case ALTX:
						quitprog = YES;
						keymain = ESCKEY;
						break;

					default:
						if ( ( alt_char_map( keymain ) ) != -1 ) {
							keymain = alt_char_map( keymain );
							if ( insertmode ) {
								if ( !insert_char( keymain, &xCursorPos, &yCursorPos ) ) {
									linetoolong( );
								}
							} else {
								if ( !ovrwrite_char( keymain, &xCursorPos, &yCursorPos ) ) {
									linetoolong( );
								}
							}
							refreshline( xCursorPos, yCursorPos );
						}
						break;
					} /* switch ( keymain ) */
				}
				adjustcol( &xCursorPos );
				while ( ( yCursorPos = findrow( ) ) > ( wind.width - 1 ) ) {
					storeline( curline );
					curline = curline->previous;
					loadtoline( curline->text );
					lineno--;
				}
				if ( !keypressed( ) ) {
					if ( !pagecomplete ) {
						showpage( );
					}
					if ( !keypressed( ) ) {
						writecolno( firstcol + xCursorPos );
						dispstrhgc( "   ", wind.col, 2, NORMALATTR );
						if ( !keypressed( ) ) {
							writepageline( );
						}
					}
				}
				if ( quitprog != YES ) {
					waitkbd( wind.col + xCursorPos, wind.row + yCursorPos );
					keymain = readkbd( );
					dispkey( keymain );
				}
			}	/* while */
		} else {	/* if filename[0] != '\0' */
			errorsound( );
		}
	} while ( !quitprog );

	if ( changeflag ) {

		blockmsg( 5 );
		dispstrhgc( "ÂѧäÁèä´é¨Ñ´à¡çºá¿éÁ¢éÍÁÙÅ µéͧ¡ÒèѴà¡çºËÃ×ÍäÁè (Y/N)?", ( 16 + center_factor ) + 7, 5, REVERSEATTR );

		keymain = 0;
		while ( ( keymain != 'n' ) && ( keymain != 'N' )
			&& ( keymain != 'y' ) && ( keymain != 'Y' ) ) {
			keymain = ebioskey( 0 ) & 0xff;
			if ( ( keymain == 'y' ) || ( keymain == 'Y' ) ) {
				writeblk( filename, sentinel->next, 0, sentinel->previous, MAXCOL );
			}
		}
	}
	settext( );

	return 0;
}
 inline void destroy() {
   reform(0,0); 
 }
Exemplo n.º 17
0
 inline void reform_chk(int rnum, bool do_chk, const char *msg) {
   if (do_chk && num != rnum) {
     throw new AzException("AzDvect::reform_chk", msg); 
   }
   reform(rnum); 
 }
Exemplo n.º 18
0
std::string get_file_path(std::string path)
{
    auto words = split(path,'/'); ///@todo check if windows, mac or linux
    return reform(words.begin(),words.end()-1,'/');
}
Exemplo n.º 19
0
 inline void reform_chk(int rnum, int cnum, bool do_chk, const char *msg) {
   if (do_chk && (row_num != rnum || col_num != cnum)) {
     throw new AzException("AzDmat::reform_or_chk", msg); 
   }
   reform(rnum, cnum); 
 }
Exemplo n.º 20
0
 AzDvect(int inp_num) : num(0), elm(NULL) {
   reform(inp_num); 
 }
Exemplo n.º 21
0
 AzDmat(int row_num, int col_num) 
          : row_num(0), col_num(0), column(NULL), isLocked(false)  {
   reform(row_num, col_num); 
 }
Exemplo n.º 22
0
std::string get_file_name(std::string file)
{
    auto words = split(get_file_from_path(file),'.');
    return reform(words.begin(),words.end()-1,'.');
}