void AccessibilityARIAGridRow::disclosedRows(AccessibilityChildrenVector& disclosedRows) { // The contiguous disclosed rows will be the rows in the table that // have an aria-level of plus 1 from this row. AccessibilityObject* parent = parentObjectUnignored(); if (!is<AccessibilityTable>(*parent) || !downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility()) return; // Search for rows that match the correct level. // Only take the subsequent rows from this one that are +1 from this row's level. int index = rowIndex(); if (index < 0) return; unsigned level = hierarchicalLevel(); auto& allRows = downcast<AccessibilityTable>(*parent).rows(); int rowCount = allRows.size(); for (int k = index + 1; k < rowCount; ++k) { AccessibilityObject* row = allRows[k].get(); // Stop at the first row that doesn't match the correct level. if (row->hierarchicalLevel() != level + 1) break; disclosedRows.append(row); } }
AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const { // The row that discloses this one is the row in the table // that is aria-level subtract 1 from this row. AccessibilityObject* parent = parentObjectUnignored(); if (!is<AccessibilityTable>(*parent) || !downcast<AccessibilityTable>(*parent).isExposableThroughAccessibility()) return nullptr; // If the level is 1 or less, than nothing discloses this row. unsigned level = hierarchicalLevel(); if (level <= 1) return nullptr; // Search for the previous row that matches the correct level. int index = rowIndex(); auto& allRows = downcast<AccessibilityTable>(parent)->rows(); int rowCount = allRows.size(); if (index >= rowCount) return nullptr; for (int k = index - 1; k >= 0; --k) { AccessibilityObject* row = allRows[k].get(); if (row->hierarchicalLevel() == level - 1) return row; } return nullptr; }
AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const { // The row that discloses this one is the row in the table // that is aria-level subtract 1 from this row. AccessibilityObject* parent = parentObjectUnignored(); if (!parent || !parent->isDataTable()) return 0; // If the level is 1 or less, than nothing discloses this row. unsigned level = hierarchicalLevel(); if (level <= 1) return 0; // Search for the previous row that matches the correct level. int index = rowIndex(); AccessibilityChildrenVector& allRows = static_cast<AccessibilityTable*>(parent)->rows(); int rowCount = allRows.size(); if (index >= rowCount) return 0; for (int k = index - 1; k >= 0; --k) { AccessibilityObject* row = allRows[k].get(); if (row->hierarchicalLevel() == level - 1) return row; } return 0; }
RealVector AccpmGenMatrix::getRow(int i) const { LaIndex rowIndex(i,i); LaIndex colIndex = index(1); AccpmVector row = RealMatrix::operator()(rowIndex, colIndex); return row; }
// This returns a matrix that is the lower-triangular part (only column // index <= row index) of the square of matrixToSquare. Eigen::MatrixXcd SymmetricComplexMassMatrix::LowerTriangleOfSquareMatrix( Eigen::MatrixXcd const& matrixToSquare ) const { Eigen::MatrixXcd valuesSquaredMatrix( numberOfRows, numberOfRows ); for( size_t rowIndex( 0 ); rowIndex < numberOfRows; ++rowIndex ) { for( size_t columnIndex( 0 ); columnIndex <= rowIndex; ++columnIndex ) { valuesSquaredMatrix.coeffRef( rowIndex, columnIndex ).real(0.0); valuesSquaredMatrix.coeffRef( rowIndex, columnIndex ).imag(0.0); for( size_t sumIndex( 0 ); sumIndex < numberOfRows; ++sumIndex ) { double temp = valuesSquaredMatrix.coeffRef( rowIndex, columnIndex ).real() + ( ( matrixToSquare.coeff( sumIndex, rowIndex ).real() * matrixToSquare.coeff( sumIndex, columnIndex ).real() ) + ( matrixToSquare.coeff( sumIndex, rowIndex ).imag() * matrixToSquare.coeff( sumIndex, columnIndex ).imag() ) ); valuesSquaredMatrix.coeffRef( rowIndex, columnIndex ).real(temp); temp = valuesSquaredMatrix.coeffRef( rowIndex, columnIndex ).imag() + ( ( matrixToSquare.coeff( sumIndex, rowIndex ).real() * matrixToSquare.coeff( sumIndex, columnIndex ).imag() ) - ( matrixToSquare.coeff( sumIndex, rowIndex ).imag() * matrixToSquare.coeff( sumIndex, columnIndex ).real() ) ); valuesSquaredMatrix.coeffRef( rowIndex, columnIndex ).imag(temp); // The Eigen routines don't bother looking at elements of // valuesSquaredMatrix where columnIndex > rowIndex, so we don't even // bother filling them with the conjugates of the transpose. } } } return valuesSquaredMatrix; }
autoConfusion Confusion_condense (Confusion me, const char32 *search, const char32 *replace, long maximumNumberOfReplaces, int use_regexp) { try { long nmatches, nstringmatches; if (my rowLabels == 0 || my columnLabels == 0) { Melder_throw (U"No row or column labels."); } autostring32vector rowLabels (strs_replace (my rowLabels, 1, my numberOfRows, search, replace, maximumNumberOfReplaces, &nmatches, &nstringmatches, use_regexp), 1, my numberOfRows); autostring32vector columnLabels (strs_replace (my columnLabels, 1, my numberOfColumns, search, replace, maximumNumberOfReplaces, &nmatches, &nstringmatches, use_regexp), 1, my numberOfColumns); autoStrings srow = Thing_new (Strings); srow -> numberOfStrings = my numberOfRows; srow -> strings = rowLabels.transfer(); autoStrings scol = Thing_new (Strings); scol -> numberOfStrings = my numberOfColumns; scol -> strings = columnLabels.transfer(); /* Find dimension of new Confusion */ autoDistributions dcol = Strings_to_Distributions (scol.get()); long nresp = dcol -> numberOfRows; autoDistributions drow = Strings_to_Distributions (srow.get()); long nstim = drow -> numberOfRows; autoConfusion thee = Confusion_create (nstim, nresp); NUMstrings_copyElements (drow -> rowLabels, thy rowLabels, 1, nstim); NUMstrings_copyElements (dcol -> rowLabels, thy columnLabels, 1, nresp); autoNUMvector<long> rowIndex (1, my numberOfRows); create_index (srow -> strings, 1, my numberOfRows, drow -> rowLabels, 1, nstim, rowIndex.peek()); autoNUMvector<long> columnIndex (1, my numberOfColumns); create_index (scol -> strings, 1, my numberOfColumns, dcol -> rowLabels, 1, nresp, columnIndex.peek()); for (long i = 1; i <= my numberOfRows; i++) { for (long j = 1; j <= my numberOfColumns; j++) { thy data [rowIndex [i]][columnIndex[j]] += my data[i][j]; } } return thee; } catch (MelderError) { Melder_throw (me, U": not condensed."); } }
// This returns the eigenvalues of the matrix, using the values for the // Lagrangian parameters from the last call of UpdateForFixedScale and the // values for the fields found in fieldConfiguration. template< typename ElementType > inline std::vector< double > MassesSquaredFromMatrix< ElementType >::MassesSquared( std::vector< double > const& fieldConfiguration ) const { Eigen::SelfAdjointEigenSolver< EigenMatrix > eigenvalueFinder( CurrentValues( fieldConfiguration ), Eigen::EigenvaluesOnly ); std::vector< double > massesSquared( numberOfRows ); for( size_t rowIndex( 0 ); rowIndex < numberOfRows; ++rowIndex ) { massesSquared[ rowIndex ] = eigenvalueFinder.eigenvalues()( rowIndex ); } return massesSquared; }
// This returns a matrix of the values of the elements for a field // configuration given by fieldConfiguration, using the values for the // Lagrangian parameters found in parameterValues. Eigen::MatrixXcd SymmetricComplexMassMatrix::MatrixToSquare( std::vector< double > const& parameterValues, std::vector< double > const& fieldConfiguration ) const { size_t rowsTimesLength( 0 ); Eigen::MatrixXcd valuesMatrix( numberOfRows, numberOfRows ); for( size_t rowIndex( 0 ); rowIndex < numberOfRows; ++rowIndex ) { for( size_t columnIndex( 0 ); columnIndex < rowIndex; ++columnIndex ) { valuesMatrix.coeffRef( rowIndex, columnIndex ).real(matrixElements[ rowsTimesLength + columnIndex ].first( parameterValues, fieldConfiguration )); valuesMatrix.coeffRef( rowIndex, columnIndex ).imag(matrixElements[ rowsTimesLength + columnIndex ].second( parameterValues, fieldConfiguration )); // We use the fact that the matrix is symmetric. valuesMatrix.coeffRef( columnIndex, rowIndex ) = valuesMatrix.coeff( rowIndex, columnIndex ); } valuesMatrix.coeffRef( rowIndex, rowIndex ).real(matrixElements[ rowsTimesLength + rowIndex ].first( parameterValues, fieldConfiguration )); valuesMatrix.coeffRef( rowIndex, rowIndex ).imag(matrixElements[ rowsTimesLength + rowIndex ].second( parameterValues, fieldConfiguration )); rowsTimesLength += numberOfRows; } return valuesMatrix; }