void Matrix::ero_2(int beg_row, int des_row, const T & scaler) { if(beg_row < 0 || beg_row >= getRow() || des_row < 0 || des_row >= getRow()) throw RowNotFound(); for(int j = 0; j < getColumn(); j++) setEntry(des_row, j, getEntry(des_row, j) + getEntry(beg_row, j) * scaler); }
//***************************************************************************** // Get the record from a Delta MetaData that corresponds to the actual record. //***************************************************************************** __checkReturn HRESULT CMiniMdRW::GetDeltaRecord( ULONG ixTbl, // Table. ULONG iRid, // Record in the table. void **ppRecord) { HRESULT hr; ULONG iMap; // RID in map table. ENCMapRec *pMap; // Row in map table. *ppRecord = NULL; // If no remap, just return record directly. if ((m_Schema.m_cRecs[TBL_ENCMap] == 0) || (ixTbl == TBL_Module) || !IsMinimalDelta()) { return getRow(ixTbl, iRid, ppRecord); } // Use the remap table to find the physical row containing this logical row. iMap = (*m_rENCRecs)[ixTbl]; IfFailRet(GetENCMapRecord(iMap, &pMap)); // Search for desired record. while ((TblFromRecId(pMap->GetToken()) == ixTbl) && (RidFromRecId(pMap->GetToken()) < iRid)) { IfFailRet(GetENCMapRecord(++iMap, &pMap)); } _ASSERTE((TblFromRecId(pMap->GetToken()) == ixTbl) && (RidFromRecId(pMap->GetToken()) == iRid)); // Relative position within table's group in map is physical rid. iRid = iMap - (*m_rENCRecs)[ixTbl] + 1; return getRow(ixTbl, iRid, ppRecord); } // CMiniMdRW::GetDeltaRecord
void Board0x88::pushMove(uchar fromSquare, uchar toSquare, uchar fromPiece, uchar capturePiece, char flags, MoveList & moveList) { uchar sourceRow = getRow(fromSquare); uchar sourceCol = getCol(fromSquare); uchar destRow = getRow(toSquare); uchar destCol = getCol(toSquare); char epCol = (mEpIndex != -1) ? getCol(mEpIndex) : -1; Move newMove; newMove.sourceRow = sourceRow; newMove.sourceCol = sourceCol; newMove.destRow = destRow; newMove.destCol = destCol; newMove.fromPiece = fromPiece; newMove.toPiece = fromPiece; newMove.castlingRights = mCastlingRights; newMove.halfMoveClock = mHalfMoveClock; newMove.enPassantCol = epCol; newMove.flags = flags; newMove.capturePiece = capturePiece; if ( fromPiece == Pawn && toSquare == mEpIndex ) newMove.flags = MoveEpCapture; if ( fromPiece == Pawn && ( ( destRow == 0 ) || ( destRow == 7) ) ) { newMove.flags |= MovePromotion; for (uchar promoPiece = Queen; promoPiece <= Knight; promoPiece++) { newMove.toPiece = promoPiece; moveList.addMove(newMove); } } else moveList.addMove(newMove); }
Matrix::Matrix(int r, int c) { setRC(r, c); mat = new T*[getRow()]; for(int i = 0; i < getRow(); i++) mat[i] = new T[getColumn()]; }
void Matrix::swapRows(unsigned int index1, unsigned int index2) { if(index1 == index2) return; Matrix temp = getRow(index1); setRow(index1, getRow(index2)); setRow(index2, temp); return; }
void MapMatrix::new_data() { if (!(getRow() >0 && getCol() > 0)) { m_row = 0; m_col = 0; m_data = nullptr; } m_data = new int[toIndex(getCol(), getRow())]; }
bool Tile::isSameRow(QPushButton *button_target, QPushButton *button_blank) { if (getRow(button_target) == getRow(button_blank)) { return 1; } else { return 0; } }
Matrix Matrix::operator+(const Matrix& right) const { if(getRow() != right.getRow() || getColumn() != right.getColumn()) throw OperandsNotMatched(); Matrix sum(getRow(), getColumn()); for(int i = 0; i < sum.getRow(); i++) for(int j = 0; j < sum.getColumn(); j++) sum.setEntry(i, j, getEntry(i, j) + right.getEntry(i, j)); return sum; }
bool MatrixF::isAffine() const { // An affine transform is defined by the following structure // // [ X X X P ] // [ X X X P ] // [ X X X P ] // [ 0 0 0 1 ] // // Where X is an orthonormal 3x3 submatrix and P is an arbitrary translation // We'll check in the following order: // 1: [3][3] must be 1 // 2: Shear portion must be zero // 3: Dot products of rows and columns must be zero // 4: Length of rows and columns must be 1 // if (m[idx(3,3)] != 1.0f) return false; if (m[idx(0,3)] != 0.0f || m[idx(1,3)] != 0.0f || m[idx(2,3)] != 0.0f) return false; Point3F one, two, three; getColumn(0, &one); getColumn(1, &two); getColumn(2, &three); if (mDot(one, two) > 0.0001f || mDot(one, three) > 0.0001f || mDot(two, three) > 0.0001f) return false; if (mFabs(1.0f - one.lenSquared()) > 0.0001f || mFabs(1.0f - two.lenSquared()) > 0.0001f || mFabs(1.0f - three.lenSquared()) > 0.0001f) return false; getRow(0, &one); getRow(1, &two); getRow(2, &three); if (mDot(one, two) > 0.0001f || mDot(one, three) > 0.0001f || mDot(two, three) > 0.0001f) return false; if (mFabs(1.0f - one.lenSquared()) > 0.0001f || mFabs(1.0f - two.lenSquared()) > 0.0001f || mFabs(1.0f - three.lenSquared()) > 0.0001f) return false; // We're ok. return true; }
// The following function takes a visible row index (hidden rows skipped) // dir: -1 = left (close), 0 = auto (toggle), 1 = right (open) void GUITable::toggleVisibleTree(s32 row_i, int dir, bool move_selection) { // Check if the chosen tree is currently open const Row *row = getRow(row_i); if (row == NULL) return; bool was_open = false; for (s32 j = 0; j < row->cellcount; ++j) { if (row->cells[j].content_type == COLUMN_TYPE_TREE) { was_open = row->cells[j].content_index == 0; break; } } // Check if the chosen tree should be opened bool do_open = !was_open; if (dir < 0) do_open = false; else if (dir > 0) do_open = true; // Close or open the tree; the heavy lifting is done by setOpenedTrees if (was_open && !do_open) closeTree(m_visible_rows[row_i]); else if (!was_open && do_open) openTree(m_visible_rows[row_i]); // Change selected row if requested by caller, // this is useful for keyboard navigation if (move_selection) { s32 sel = row_i; if (was_open && do_open) { // Move selection to first child const Row *maybe_child = getRow(sel + 1); if (maybe_child && maybe_child->indent > row->indent) sel++; } else if (!was_open && !do_open) { // Move selection to parent assert(getRow(sel) != NULL); while (sel > 0 && getRow(sel - 1)->indent >= row->indent) sel--; sel--; if (sel < 0) // was root already selected? sel = row_i; } if (sel != m_selected) { m_selected = sel; autoScroll(); sendTableEvent(0, false); } } }
Matrix::Matrix(const Matrix & right) { setRC(right.getRow(), right.getColumn()); mat = new T*[getRow()]; for(int i = 0; i < getRow(); i++) mat[i] = new T[getColumn()]; for(int i = 0; i < getRow(); i++) for(int j = 0; j < getColumn(); j++) mat[i][j] = right.getEntry(i, j); }
void Matrix::ero_3(int row_1, int row_2) { if(row_1 < 0 || row_1 >= getRow() || row_2 < 0 || row_2 >= getRow()) throw RowNotFound(); for(int j = 0; j < getColumn(); j++) { T temp = getEntry(row_1, j); setEntry(row_1, j, getEntry(row_2, j)); setEntry(row_2, j, temp); } }
std::vector<Move> Rook::getPossibleMoves(){ std::vector<Move> possible; for(int i = getRow() - 1; i >= 0; i--){ if (getBoard()->board[i][getColumn()] == NULL){ possible.push_back(Move(i, getColumn())); } else if (getBoard()->board[i][getColumn()]->isWhite() != isWhite()){ possible.push_back(Move(i, getColumn())); break; } else{ break; } } for(int i = getRow() + 1; i < 8; i++){ if (getBoard()->board[i][getColumn()] == NULL){ possible.push_back(Move(i, getColumn())); } else if (getBoard()->board[i][getColumn()]->isWhite() != isWhite()){ possible.push_back(Move(i, getColumn())); break; } else{ break; } } for (int i = getColumn() - 1; i >= 0; i--){ if (getBoard()->board[getRow()][i] == NULL){ possible.push_back(Move(getRow(), i)); } else if (getBoard()->board[getRow()][i]->isWhite() != isWhite()){ possible.push_back(Move(getRow(), i)); break; } else{ break; } } for (int i = getColumn() + 1; i < 8; i++){ if (getBoard()->board[getRow()][i] == NULL){ possible.push_back(Move(getRow(), i)); } else if (getBoard()->board[getRow()][i]->isWhite() != isWhite()){ possible.push_back(Move(getRow(), i)); break; } else{ break; } } return possible; }
BooleanMatrix BooleanMatrix::BooleanProduct(const BooleanMatrix & bm) const { assert(getColums() == bm.getRow()); BooleanMatrix temp(getRow(), bm.getColums()); for (int i = 1; i <= getRow(); i++) { for (int j = 1; j <= bm.getColums(); j++) { for (int k = 1; k <= getColums(); k++) { temp.matrix[(i - 1) * temp.columns + j - 1] |= getElement(i, k) & bm.getElement(k, j); } } } return temp; }
// 5 void endFile(FILE* file, DynamicTable* symbols, Token token) { DynamicTable search; int i; i = lookUpForCell(*symbols, "main", "procedure"); if(i == -1) { printf("ERROR: unexpected behavior defining main procedure.\n"); fprintf(file, "ERROR: unexpected behavior defining main procedure.\n"); fflush(stdout); fflush(file); system("PAUSE"); exit(5); } else { if(!getRow(*symbols, i)->defined) { printf("WARNING: main function not defined.\n"); fflush(stdout); defineRow(symbols, i); } } i = lookForUndefined(*symbols); // cannot accept file with undefined labels if(i >= 0) { printf("ERROR: label \"%s\" used but not defined.\n", getRow(*symbols, i)->name); fprintf(file, "ERROR: label \"%s\" used but not defined.\n", getRow(*symbols, i)->name); fflush(stdout); fflush(file); system("PAUSE"); exit(5); } // the end of the file must contain the data allocation for(search = *symbols; search != NULL; search = search->next) { if(!strcmp(search->class, "variable") && strncmp(search->nick, "_param", 6)) { fprintf(file, "%s\t K\t/0000\n", search->name); fflush(file); } } // constant: 0 fprintf(file, "_nil\t K\t/0000\n"); // constant: -1 fprintf(file, "_inv\t K\t/FFFF\n"); // EOF fprintf(file, "\t#\t_start\n"); fflush(file); }
// Perform inverse on full 4x4 matrix. Used in special cases only, so not at all optimized. bool MatrixF::fullInverse() { Point4F a,b,c,d; getRow(0,&a); getRow(1,&b); getRow(2,&c); getRow(3,&d); // det = a0*b1*c2*d3 - a0*b1*c3*d2 - a0*c1*b2*d3 + a0*c1*b3*d2 + a0*d1*b2*c3 - a0*d1*b3*c2 - // b0*a1*c2*d3 + b0*a1*c3*d2 + b0*c1*a2*d3 - b0*c1*a3*d2 - b0*d1*a2*c3 + b0*d1*a3*c2 + // c0*a1*b2*d3 - c0*a1*b3*d2 - c0*b1*a2*d3 + c0*b1*a3*d2 + c0*d1*a2*b3 - c0*d1*a3*b2 - // d0*a1*b2*c3 + d0*a1*b3*c2 + d0*b1*a2*c3 - d0*b1*a3*c2 - d0*c1*a2*b3 + d0*c1*a3*b2 F32 det = a.x*b.y*c.z*d.w - a.x*b.y*c.w*d.z - a.x*c.y*b.z*d.w + a.x*c.y*b.w*d.z + a.x*d.y*b.z*c.w - a.x*d.y*b.w*c.z - b.x*a.y*c.z*d.w + b.x*a.y*c.w*d.z + b.x*c.y*a.z*d.w - b.x*c.y*a.w*d.z - b.x*d.y*a.z*c.w + b.x*d.y*a.w*c.z + c.x*a.y*b.z*d.w - c.x*a.y*b.w*d.z - c.x*b.y*a.z*d.w + c.x*b.y*a.w*d.z + c.x*d.y*a.z*b.w - c.x*d.y*a.w*b.z - d.x*a.y*b.z*c.w + d.x*a.y*b.w*c.z + d.x*b.y*a.z*c.w - d.x*b.y*a.w*c.z - d.x*c.y*a.z*b.w + d.x*c.y*a.w*b.z; if (mFabs(det)<0.00001f) return false; Point4F aa,bb,cc,dd; aa.x = b.y*c.z*d.w - b.y*c.w*d.z - c.y*b.z*d.w + c.y*b.w*d.z + d.y*b.z*c.w - d.y*b.w*c.z; aa.y = -a.y*c.z*d.w + a.y*c.w*d.z + c.y*a.z*d.w - c.y*a.w*d.z - d.y*a.z*c.w + d.y*a.w*c.z; aa.z = a.y*b.z*d.w - a.y*b.w*d.z - b.y*a.z*d.w + b.y*a.w*d.z + d.y*a.z*b.w - d.y*a.w*b.z; aa.w = -a.y*b.z*c.w + a.y*b.w*c.z + b.y*a.z*c.w - b.y*a.w*c.z - c.y*a.z*b.w + c.y*a.w*b.z; bb.x = -b.x*c.z*d.w + b.x*c.w*d.z + c.x*b.z*d.w - c.x*b.w*d.z - d.x*b.z*c.w + d.x*b.w*c.z; bb.y = a.x*c.z*d.w - a.x*c.w*d.z - c.x*a.z*d.w + c.x*a.w*d.z + d.x*a.z*c.w - d.x*a.w*c.z; bb.z = -a.x*b.z*d.w + a.x*b.w*d.z + b.x*a.z*d.w - b.x*a.w*d.z - d.x*a.z*b.w + d.x*a.w*b.z; bb.w = a.x*b.z*c.w - a.x*b.w*c.z - b.x*a.z*c.w + b.x*a.w*c.z + c.x*a.z*b.w - c.x*a.w*b.z; cc.x = b.x*c.y*d.w - b.x*c.w*d.y - c.x*b.y*d.w + c.x*b.w*d.y + d.x*b.y*c.w - d.x*b.w*c.y; cc.y = -a.x*c.y*d.w + a.x*c.w*d.y + c.x*a.y*d.w - c.x*a.w*d.y - d.x*a.y*c.w + d.x*a.w*c.y; cc.z = a.x*b.y*d.w - a.x*b.w*d.y - b.x*a.y*d.w + b.x*a.w*d.y + d.x*a.y*b.w - d.x*a.w*b.y; cc.w = -a.x*b.y*c.w + a.x*b.w*c.y + b.x*a.y*c.w - b.x*a.w*c.y - c.x*a.y*b.w + c.x*a.w*b.y; dd.x = -b.x*c.y*d.z + b.x*c.z*d.y + c.x*b.y*d.z - c.x*b.z*d.y - d.x*b.y*c.z + d.x*b.z*c.y; dd.y = a.x*c.y*d.z - a.x*c.z*d.y - c.x*a.y*d.z + c.x*a.z*d.y + d.x*a.y*c.z - d.x*a.z*c.y; dd.z = -a.x*b.y*d.z + a.x*b.z*d.y + b.x*a.y*d.z - b.x*a.z*d.y - d.x*a.y*b.z + d.x*a.z*b.y; dd.w = a.x*b.y*c.z - a.x*b.z*c.y - b.x*a.y*c.z + b.x*a.z*c.y + c.x*a.y*b.z - c.x*a.z*b.y; setRow(0,aa); setRow(1,bb); setRow(2,cc); setRow(3,dd); mul(1.0f/det); return true; }
void Curses::getVerticalViewport(size_t &first_row, size_t &nrows) { CursesContainer *p=getParent(); if (!p) { first_row=0; nrows=getHeight(); return; } p->getVerticalViewport(first_row, nrows); size_t r=getRow(); size_t h=getHeight(); if (r + h <= first_row || r >= first_row + nrows) { first_row=nrows=0; return; } if (first_row < r) { nrows -= r-first_row; first_row=r; } first_row -= r; if (first_row + nrows > h) nrows=h-first_row; }
int CursesFileReq::Dirlist::getHeight() const { int h=parent->getHeight(); int r=getRow(); return (r < h ? h-r:1); }
bool WHotSpotList::leftBttnDn( int x, int y, WMouseKeyFlags f ) //------------------------------------------------------------ { int row = getRow( WPoint( x, y ) ) + _topIndex; if( row < 0 ) row = 0; if( row >= count() ) row = count() - 1; if( row < 0 ) { // count == 0 return FALSE; } if( _hs != NULL ) { WPoint hotSize; _hs->hotSpotSize( getHotSpot( row, FALSE ), hotSize ); int hotOffset = getHotOffset( row ); if( x > hotOffset && x < hotOffset + hotSize.x() ) { _hotPressIdx = row; } } _leftDown = TRUE; mouseMove( x, y, f ); return TRUE; }
void Sprite::setColumn(int column, int row) { const ResAnim* rs = getResAnim(); if (row == -1) row = getRow(); setAnimFrame(rs, column, row); }
bool Stone::init(int id) { _id = id; _type = getType(id); _row = getRow(id); _col = getCol(id); isRed = _id<16; const char* bfiles[] = { "bche.png", "bma.png", "bpao.png", "bzu.png", "bxiang.png", "bshi.png", "bjiang.png" }; const char* rfiles[] = { "rche.png", "rma.png", "rpao.png", "rbing.png", "rxiang.png", "rshi.png", "rshuai.png" }; if (isRed) { CCSprite::initWithFile(rfiles[_type]); } else { CCSprite::initWithFile(bfiles[_type]); } setPosition(getPos()); setScale(1.1f); return true; };
// 24 void setReturn2(FILE* file, DynamicTable* symbols, Token token) { int i; if(!strcmp(identifier, "")) { fprintf(file, "%s\tLV\t/%04X\n", label, constant); constant = -1; } else { i = lookUpForCell(*symbols, identifier, "variable"); if(i >= 0) { fprintf(file, "%s\tLD\t%s\n", label, getRow(*symbols, i)->nick); strcpy(identifier, ""); } else { printf("ERROR: symbol \"%s\" could not be resolved.\n", identifier); fprintf(file, "ERROR: symbol \"%s\" could not be resolved.\n", identifier); fflush(stdout); fflush(file); system("PAUSE"); exit(5); } } strcpy(label, ""); fprintf(file, "\tRS\t%s\n", procedure); fflush(file); }
ArrayRef<char> CameraImageWrapper::getMatrix() const { int width = getWidth(); int height = getHeight(); char* matrix = new char[width*height]; char* m = matrix; for(int y=0; y<height; y++) { ArrayRef<char> tmpRow; tmpRow = getRow(y, ArrayRef<char>(width)); #if __cplusplus > 199711L memcpy(m, tmpRow->values().data(), width); #else memcpy(m, &tmpRow->values()[0], width); #endif m += width * sizeof(unsigned char); //delete tmpRow; } //pMatrix = matrix; ArrayRef<char> arr = ArrayRef<char>(matrix, width*height); if(matrix) delete matrix; return arr; }
bool searchMatrix(vector<vector<int> >& matrix, int target) { if (matrix.empty() && target) return false; if (target > matrix[matrix.size() - 1][matrix[0].size() - 1]) return false; if (target < matrix[0][0]) return false; int row = getRow(matrix, 0, matrix.size() - 1, target); return binarySearch(matrix, row, target); }
bool WHotSpotList::leftBttnUp( int x, int y, WMouseKeyFlags f ) //------------------------------------------------------------ { mouseMove( x, y, f ); _leftDown = FALSE; if( _inHotZone && getRow( WPoint( x, y ) ) + _topIndex == _hotPressIdx ) { // have to set false before calling invalidateRow(). _inHotZone = FALSE; if( _selected != _hotPressIdx ) { int oldSel = _selected; _selected = _hotPressIdx; invalidateRow( oldSel - _topIndex ); } if( _hotPressClient && _hotPress ) (_hotPressClient->*_hotPress)( this ); invalidateRow( _selected - _topIndex ); } _inHotZone = FALSE; _hotPressIdx = -1; changed(); return TRUE; }
s32 GUITable::getCellAt(s32 x, s32 row_i) const { const Row *row = getRow(row_i); if (row == NULL) return -1; // Use binary search to find cell in row s32 rel_x = x - AbsoluteRect.UpperLeftCorner.X - 1; s32 jmin = 0; s32 jmax = row->cellcount - 1; while (jmin < jmax) { s32 pivot = jmin + (jmax - jmin) / 2; assert(pivot >= 0 && pivot < row->cellcount); const Cell *cell = &row->cells[pivot]; if (rel_x >= cell->xmin && rel_x <= cell->xmax) return pivot; else if (rel_x < cell->xmin) jmax = pivot - 1; else jmin = pivot + 1; } if (jmin >= 0 && jmin < row->cellcount && rel_x >= row->cells[jmin].xmin && rel_x <= row->cells[jmin].xmax) return jmin; else return -1; }
const GFF4Struct *GDAFile::getRowColumn(size_t row, const Common::UString &name, size_t &column) const { const GFF4Struct *gdaRow = getRow(row); if (!gdaRow || ((column = findColumn(name)) == kInvalidColumn)) return 0; return gdaRow; }
// 13-Mar-2000 jdh removed problem with dragging and entry into the middle of another entry void CWListEntry::reset(CListCtrl &clc, int iOldRowCount, int iNewStartingRow) { clc.LockWindowUpdate(); //don't want to show the remove int iStartingRow; if(iNewStartingRow==-1) iStartingRow = getStartingRow(clc); else { iStartingRow = iNewStartingRow; // jdh 3/13/2000 if we're moving down, we need to subtract // the rows we will remove from above from the iNewStartingRow if (iStartingRow > this->getStartingRow(clc)) iStartingRow -= this->rowCount(); } ASSERTX(iStartingRow >=0); // 1) remove ourselves from the list control int iRow = getRow(clc); removeFromListCtrl(clc, iOldRowCount); // 2) add ourselves back in // made this change for drag & drop addYourRowsToListCtrl(clc, iStartingRow); // iRow); clc.UnlockWindowUpdate(); //don't want to show the remove }
const GFF4Struct *GDAFile::getRowColumn(size_t row, uint32 hash, size_t &column) const { const GFF4Struct *gdaRow = getRow(row); if (!gdaRow || ((column = findColumn(hash)) == kInvalidColumn)) return 0; return gdaRow; }
virtual DoubleVector& rowNorms() const { DoubleVector& rowNRMs = *new DenseVector(_rows.size()); for (unsigned int i = 0, m = _rows.size(); i < m; i++) rowNRMs.set(i, getRow(i).DNRM2()); return rowNRMs; }