idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
36,100
public void deleteCookie ( String cookieName ) { String action = "Deleting cookie <i>" + cookieName + "</i>" ; String expected = "Cookie <i>" + cookieName + "</i> is removed" ; try { Cookie cookie = driver . manage ( ) . getCookieNamed ( cookieName ) ; if ( cookie == null ) { reporter . fail ( action , expected , "Unab...
Deletes a stored cookie indicated by the cookieName for this particular test . If the cookie by the provided name isn t present than an error will be logged and recorded
196
33
36,101
public void deleteAllCookies ( ) { String action = "Deleting all cookies" ; String expected = "All cookies are removed" ; try { driver . manage ( ) . deleteAllCookies ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to remove all cookies. " + e . getMessage ( ) ) ; log . warn ( e ) ; return...
Delete all stored cookies for this particular test
100
8
36,102
public void resize ( int width , int height ) { String action = "Resizing browser to " + width + " x " + height ; String expected = "Browser is resized to " + width + " x " + height ; try { Dimension dimension = new Dimension ( width , height ) ; driver . manage ( ) . window ( ) . setSize ( dimension ) ; } catch ( Exce...
Resizes the current window to the specified size
133
9
36,103
public void scroll ( int desiredPosition ) { String action = "Scrolling page by " + desiredPosition + " pixels" ; String expected = "Page is scrolled down " + desiredPosition + " pixels" ; Long newPosition ; try { JavascriptExecutor jse = ( JavascriptExecutor ) driver ; Long initialPosition = ( Long ) jse . executeScri...
An custom script to scroll to a given position on the page using javascript . If the browser being used doesn t support javascript or the page isn t long enough to support scrolling to the desired position than an error will be logged and recorded
267
46
36,104
public void openNewWindow ( String url ) { String action = "Opening new window to url " + url ; String expected = "New window is opened to url " + url ; try { JavascriptExecutor jse = ( JavascriptExecutor ) driver ; jse . executeScript ( "window.open('" + url + "','_blank');" ) ; } catch ( Exception e ) { reporter . fa...
Opens a new tab and have it selected . The page provided will be loaded
196
16
36,105
public void switchToNewWindow ( ) { String action = "Switching to the new window" ; String expected = "New window is available and selected" ; try { parentWindow = driver . getWindowHandle ( ) ; for ( String winHandle : driver . getWindowHandles ( ) ) { driver . switchTo ( ) . window ( winHandle ) ; } } catch ( Excepti...
Switches to the next window . This is an alternative to switchNextTab or switchPreviousTab as this works better for some systems and environments that others .
132
31
36,106
public void switchToParentWindow ( ) { String action = "Switching back to parent window" ; String expected = "Parent window is available and selected" ; try { driver . switchTo ( ) . window ( parentWindow ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Parent window was unable to be selected. " + e...
Switches to the originally opened window . This is an alternative to switchNextTab or switchPreviousTab as this works better for some systems and environments that others .
104
32
36,107
public void closeCurrentWindow ( ) { String action = "Closing currently selected window" ; String expected = "Current window is closed" ; try { driver . close ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Current window was unable to be closed. " + e . getMessage ( ) ) ; log . warn ( e ) ; retu...
Close the currently selected window . After this window is closed ensure that focus is shifted to the next window using switchToNewWindow or switchToParentWindow methods . This is an alternative to closeTab as this works better for some systems and environments that others .
93
51
36,108
public void selectMainWindow ( ) { String action = "Switching to main window" ; String expected = "Main window is selected" ; try { driver . switchTo ( ) . defaultContent ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Main window was not selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; re...
Select the main window . Used for returning to the main content after selecting a frame . If there are nested frames the main content will be selected not the next frame in the parent child relationship
97
37
36,109
public void selectParentFrame ( ) { String action = "Switching to parent frame" ; String expected = "Parent frame is selected" ; try { driver . switchTo ( ) . parentFrame ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Parent frame was not selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; r...
Select the parent frame . Used for returning to the next frame up after selecting a frame . If there are nested frames the main content won t be selected however the next frame in the parent child relationship will be
97
41
36,110
public void acceptCertificate ( ) { String action = "Clicking override link to accept ssl certificate" ; String result = "Override link clicked" ; //for IE and Edge if ( browser . getName ( ) == BrowserName . INTERNETEXPLORER || browser . getName ( ) == BrowserName . EDGE ) { Element overrideLink = newElement ( Locator...
Safari Edge and IE don t recognize the allowInsecureCert capability . As a result an alternative method is provided in order to manually accept the problematic certificate
219
32
36,111
private boolean isNotConfirmation ( String action , String expected ) { // wait for element to be present if ( ! is . confirmationPresent ( ) ) { waitFor . confirmationPresent ( ) ; } if ( ! is . confirmationPresent ( ) ) { reporter . fail ( action , expected , "Unable to click confirmation as it is not present" ) ; re...
Determines if a confirmation is present or not and can be interacted with . If it s not present an indication that the confirmation can t be clicked on is written to the log file
87
37
36,112
private boolean isNotPrompt ( String action , String expected , String perform ) { // wait for element to be present if ( ! is . promptPresent ( ) ) { waitFor . promptPresent ( ) ; } if ( ! is . promptPresent ( ) ) { reporter . fail ( action , expected , "Unable to " + perform + " prompt as it is not present" ) ; retur...
Determines if a prompt is present or not and can be interacted with . If it s not present an indication that the confirmation can t be clicked on is written to the log file
94
37
36,113
public void typeIntoPrompt ( String text ) { String action = "Typing text '" + text + "' into prompt" ; String expected = "Prompt is present and enabled to have text " + text + " typed in" ; if ( isNotPrompt ( action , expected , "type into" ) ) { return ; } try { Alert alert = driver . switchTo ( ) . alert ( ) ; alert...
Type text into a prompt box
163
6
36,114
@ Override public void titleMatches ( String expectedTitlePattern ) { String title = checkTitleMatches ( expectedTitlePattern , 0 , 0 ) ; assertTrue ( "Title Mismatch: title of '" + title + DOES_NOT_MATCH_PATTERN + expectedTitlePattern + "'" , title . matches ( expectedTitlePattern ) ) ; }
Verifies the provided title matches the actual title of the current page the application is on . This information will be logged and recorded with a screenshot for traceability and added debugging support .
77
36
36,115
@ Override public void alertMatches ( String expectedAlertPattern ) { String alert = checkAlertMatches ( expectedAlertPattern , 0 , 0 ) ; assertTrue ( "Alert Text Mismatch: alert text of '" + alert + DOES_NOT_MATCH_PATTERN + expectedAlertPattern + "'" , alert . matches ( expectedAlertPattern ) ) ; }
Asserts that an alert present on the page has content matching the expected patten . This information will be logged and recorded with a screenshot for traceability and added debugging support .
79
36
36,116
@ Override public void confirmationMatches ( String expectedConfirmationPattern ) { String confirmation = checkConfirmationMatches ( expectedConfirmationPattern , 0 , 0 ) ; assertTrue ( "Confirmation Text Mismatch: confirmation text of '" + confirmation + DOES_NOT_MATCH_PATTERN + expectedConfirmationPattern + "'" , con...
Asserts that a confirmation present on the page has content matching the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support .
85
35
36,117
@ Override public void promptMatches ( String expectedPromptPattern ) { String prompt = checkPromptMatches ( expectedPromptPattern , 0 , 0 ) ; assertTrue ( "Prompt Text Mismatch: prompt text of '" + prompt + DOES_NOT_MATCH_PATTERN + expectedPromptPattern + "'" , prompt . matches ( expectedPromptPattern ) ) ; }
Asserts that a prompt present on the page has content matching the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support .
85
35
36,118
@ Override public void cookieEquals ( String cookieName , String expectedCookieValue ) { assertEquals ( "Cookie Value Mismatch" , expectedCookieValue , checkCookieEquals ( cookieName , expectedCookieValue , 0 , 0 ) ) ; }
Asserts that a cookies with the provided name has a value equal to the expected value . This information will be logged and recorded with a screenshot for traceability and added debugging support .
59
37
36,119
@ Override public void cookieMatches ( String cookieName , String expectedCookiePattern ) { String cookie = checkCookieMatches ( cookieName , expectedCookiePattern , 0 , 0 ) ; assertTrue ( "Cookie Value Mismatch: cookie value of '" + cookie + DOES_NOT_MATCH_PATTERN + expectedCookiePattern + "'" , cookie . matches ( exp...
Asserts that a cookies with the provided name has a value matching the expected pattern . This information will be logged and recorded with a screenshot for traceability and added debugging support .
92
36
36,120
public void clazz ( String expectedClass ) { String clazz = checkClazz ( expectedClass , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , clazz ) ; assertTrue ( "Class Mismatch: class of '" + clazz + DOES_NOT_CONTAIN + expectedClass + "'" , clazz . contains ( expectedClass ) ) ; }
Asserts that the element s class contains the provided expected class . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
84
48
36,121
public void attribute ( String expectedAttribute ) { Set < String > attributes = checkAttribute ( expectedAttribute , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , attributes ) ; assertTrue ( "Attribute not found: element attributes of '" + String . join ( "," , attributes ) + DOES_NOT_CONTAIN + expectedAttribute + "'" ...
Asserts that the element contains the provided expected attribute . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
89
46
36,122
public void text ( String expectedText ) { String text = checkText ( expectedText , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , text ) ; assertTrue ( "Text not found: element text of '" + text + DOES_NOT_CONTAIN + expectedText + "'" , text . contains ( expectedText ) ) ; }
Asserts that the element s text contains the provided expected text . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
78
48
36,123
@ SuppressWarnings ( "squid:S2259" ) public void value ( String expectedValue ) { String value = checkValue ( expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( value == null && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not input" ; } assertNotNull ( reason , value ) ; assertTrue ( "Val...
Asserts that the element s value contains the provided expected value . If the element isn t present or an input this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
128
51
36,124
public void selectOption ( String expectedOption ) { String [ ] options = checkSelectOption ( expectedOption , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( options == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , options ) ; assertTrue ( "Option not foun...
Asserts that the element s options contains the provided expected option . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
132
51
36,125
public void selectOptions ( int numOfOptions ) { int options = checkSelectOptions ( numOfOptions , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( options < 0 && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertTrue ( reason , options >= 0 ) ; assertEquals ( "Number of options mismatch"...
Asserts that the element has the expected number of options . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
98
50
36,126
public void columns ( int numOfColumns ) { int columns = checkColumns ( numOfColumns , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( columns < 0 && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not table" ; } assertTrue ( reason , columns >= 0 ) ; assertEquals ( "Number of columns mismatch" , numOfCol...
Asserts that the element has the expected number of columns . If the element isn t present or a table this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
99
50
36,127
public void rows ( int numOfRows ) { int rows = checkRows ( numOfRows , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( rows < 0 && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not table" ; } assertTrue ( reason , rows >= 0 ) ; assertEquals ( "Number of rows mismatch" , numOfRows , rows ) ; }
Asserts that the element has the expected number of rows . If the element isn t present or a table this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support .
99
50
36,128
private void recordResult ( ITestResult result ) { // finalize our output file Reporter reporter = ( Reporter ) result . getAttribute ( REPORTER ) ; String htmlFilename = "" ; String pdfFilename = "" ; if ( reporter != null ) { // subtracting one from the status ordinal to map ITestResult to Success reporter . finalize...
Checks to see if the test execution was performed on SauceLabs or not . If it was this reaches out to Sauce in order to update the execution results
638
32
36,129
@ SuppressWarnings ( "unchecked" ) protected < T > List < T > getDialogListeners ( Class < T > listenerInterface ) { final Fragment targetFragment = getTargetFragment ( ) ; List < T > listeners = new ArrayList < T > ( 2 ) ; if ( targetFragment != null && listenerInterface . isAssignableFrom ( targetFragment . getClass ...
Utility method for acquiring all listeners of some type for current instance of DialogFragment
160
18
36,130
private void modifyButtonsBasedOnScrollableContent ( boolean scrollable ) { if ( getView ( ) == null ) { return ; } View vButtonDivider = getView ( ) . findViewById ( R . id . sdl_button_divider ) ; View vButtonsBottomSpace = getView ( ) . findViewById ( R . id . sdl_buttons_bottom_space ) ; View vDefaultButtons = getV...
Button divider should be shown only if the content is scrollable .
291
14
36,131
@ StyleRes private int resolveTheme ( ) { // First check if getTheme() returns some usable theme. int theme = getTheme ( ) ; if ( theme != 0 ) { return theme ; } // Get the light/dark attribute from the Activity's Theme. boolean useLightTheme = isActivityThemeLight ( ) ; // Now check if developer overrides the Activity...
Resolves the theme to be used for the dialog .
207
11
36,132
private boolean isActivityThemeLight ( ) { try { TypedValue val = new TypedValue ( ) ; //Reading attr value from current theme getActivity ( ) . getTheme ( ) . resolveAttribute ( R . attr . isLightTheme , val , true ) ; //Passing the resource ID to TypedArray to get the attribute value TypedArray styledAttributes = get...
This method resolves the current theme declared in the manifest
159
10
36,133
@ Override public Long processIdentifier ( Object id ) { Objects . requireNonNull ( id , "Element identifier cannot be null" ) ; // check for Long if ( id instanceof Long ) return ( Long ) id ; // check for numeric types if ( id instanceof Number ) return ( ( Number ) id ) . longValue ( ) ; // check for string if ( id ...
Process the given identifier converting it to the correct type if necessary .
134
13
36,134
@ Override public String matchPredicateOperand ( String alias ) { Objects . requireNonNull ( alias , "alias cannot be null" ) ; // alias.identifier return alias + "." + idFieldName ; }
Gets the MATCH WHERE predicate operand .
47
10
36,135
public void createIndex ( String label , String propertyName ) { Objects . requireNonNull ( label , "label cannot be null" ) ; Objects . requireNonNull ( propertyName , "propertyName cannot be null" ) ; // get current session Neo4JSession session = currentSession ( ) ; // transaction should be ready for io operations t...
Creates an index in the neo4j database .
113
11
36,136
private int getIndex ( int ind ) { // Try to find column index int i = Arrays . binarySearchGreater ( index , ind , 0 , used ) ; // Found if ( i < used && index [ i ] == ind ) return i ; int [ ] newIndex = index ; double [ ] newData = data ; // Check available memory if ( ++ used > data . length ) { // If zero-length, ...
Tries to find the index . If it is not found a reallocation is done and a new index is returned .
298
25
36,137
private void setup ( ) { st = new StreamTokenizer ( this ) ; st . resetSyntax ( ) ; st . eolIsSignificant ( false ) ; st . lowerCaseMode ( true ) ; // Parse numbers as words st . wordChars ( ' ' , ' ' ) ; st . wordChars ( ' ' , ' ' ) ; // Characters as words st . wordChars ( ' ' , ' ' ) ; // Skip comments st . commentC...
Sets up the stream tokenizer
141
7
36,138
public void add ( int num , int [ ] indices ) { for ( int i = 0 ; i < indices . length ; ++ i ) indices [ i ] += num ; }
Shifts the indices . Useful for converting between 0 - and 1 - based indicing .
37
18
36,139
private String readTrimmedLine ( ) throws IOException { String line = readLine ( ) ; if ( line != null ) return line . trim ( ) ; else throw new EOFException ( ) ; }
Reads a line and trims it of surrounding whitespace
44
12
36,140
public MatrixInfo readMatrixInfo ( ) throws IOException { String [ ] component = readTrimmedLine ( ) . split ( " +" ) ; if ( component . length != 5 ) throw new IOException ( "Current line unparsable. It must consist of 5 tokens" ) ; // Read header if ( ! component [ 0 ] . equalsIgnoreCase ( "%%MatrixMarket" ) ) throw ...
Reads the matrix info for the Matrix Market exchange format . The line must consist of exactly 5 space - separated entries the first being %%MatrixMarket
553
29
36,141
public VectorInfo readVectorInfo ( ) throws IOException { String [ ] component = readTrimmedLine ( ) . split ( " +" ) ; if ( component . length != 4 ) throw new IOException ( "Current line unparsable. It must consist of 4 tokens" ) ; // Read header if ( ! component [ 0 ] . equalsIgnoreCase ( "%%MatrixMarket" ) ) throw ...
Reads the vector info for the Matrix Market exchange format . The line must consist of exactly 4 space - separated entries the first being %%MatrixMarket
379
29
36,142
public MatrixSize readMatrixSize ( MatrixInfo info ) throws IOException { // Always read the matrix size int numRows = getInt ( ) , numColumns = getInt ( ) ; // For coordinate matrices we also read the number of entries if ( info . isDense ( ) ) return new MatrixSize ( numRows , numColumns , info ) ; else { int numEntr...
Reads in the size of a matrix . Skips initial comments
110
13
36,143
public MatrixSize readArraySize ( ) throws IOException { int numRows = getInt ( ) , numColumns = getInt ( ) ; return new MatrixSize ( numRows , numColumns , numRows * numColumns ) ; }
Reads in the size of an array matrix . Skips initial comments
54
14
36,144
public MatrixSize readCoordinateSize ( ) throws IOException { int numRows = getInt ( ) , numColumns = getInt ( ) , numEntries = getInt ( ) ; return new MatrixSize ( numRows , numColumns , numEntries ) ; }
Reads in the size of a coordinate matrix . Skips initial comments
60
14
36,145
public VectorSize readVectorSize ( VectorInfo info ) throws IOException { // Always read the vector size int size = getInt ( ) ; // For coordinate vectors we also read the number of entries if ( info . isDense ( ) ) return new VectorSize ( size ) ; else { int numEntries = getInt ( ) ; return new VectorSize ( size , num...
Reads in the size of a vector . Skips initial comments
84
13
36,146
public VectorSize readVectorCoordinateSize ( ) throws IOException { int size = getInt ( ) , numEntries = getInt ( ) ; return new VectorSize ( size , numEntries ) ; }
Reads in the size of a coordinate vector . Skips initial comments
44
14
36,147
public void readArray ( double [ ] dataR , double [ ] dataI ) throws IOException { int size = dataR . length ; if ( size != dataI . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) { dataR [ i ] = getDouble ( ) ; dataI [ i ] = getDouble ( ) ; } ...
Reads the array data . The first array will contain real entries while the second contain imaginary entries
96
19
36,148
public void readCoordinate ( int [ ] index , double [ ] data ) throws IOException { int size = index . length ; if ( size != data . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) { index [ i ] = getInt ( ) ; data [ i ] = getDouble ( ) ; } }
Reads a coordinate vector
91
5
36,149
public void readCoordinate ( int [ ] index , float [ ] dataR , float [ ] dataI ) throws IOException { int size = index . length ; if ( size != dataR . length || size != dataI . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) { index [ i ] = get...
Reads a coordinate vector . First data array contains real entries and the second contains imaginary entries
118
18
36,150
public void readPattern ( int [ ] index ) throws IOException { int size = index . length ; for ( int i = 0 ; i < size ; ++ i ) index [ i ] = getInt ( ) ; }
Reads a pattern vector
46
5
36,151
public void readCoordinate ( int [ ] row , int [ ] column , double [ ] data ) throws IOException { int size = row . length ; if ( size != column . length || size != data . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) { row [ i ] = getInt ( )...
Reads a coordinate matrix
112
5
36,152
public void readPattern ( int [ ] row , int [ ] column ) throws IOException { int size = row . length ; if ( size != column . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) { row [ i ] = getInt ( ) ; column [ i ] = getInt ( ) ; } }
Reads a pattern matrix
90
5
36,153
public void readCoordinate ( int [ ] row , int [ ] column , double [ ] dataR , double [ ] dataI ) throws IOException { int size = row . length ; if ( size != column . length || size != dataR . length || size != dataI . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i =...
Reads a coordinate matrix . First data array contains real entries and the second contains imaginary entries
139
18
36,154
private float getFloat ( ) throws IOException { st . nextToken ( ) ; if ( st . ttype == StreamTokenizer . TT_WORD ) return Float . parseFloat ( st . sval ) ; else if ( st . ttype == StreamTokenizer . TT_EOF ) throw new EOFException ( "End-of-File encountered during parsing" ) ; else throw new IOException ( "Unknown tok...
Reads a float
96
4
36,155
private int getDiagSize ( int diagonal ) { if ( diagonal < 0 ) return Math . min ( numRows + diagonal , numColumns ) ; else return Math . min ( numRows , numColumns - diagonal ) ; }
Finds the size of the requested diagonal to be allocated
51
11
36,156
public PermutationMatrix getP ( ) { PermutationMatrix perm = PermutationMatrix . fromPartialPivots ( piv ) ; perm . transpose ( ) ; return perm ; }
Returns the permutation matrix .
42
6
36,157
public QRP factor ( Matrix A ) { if ( Q . numRows ( ) != A . numRows ( ) ) throw new IllegalArgumentException ( "Q.numRows() != A.numRows()" ) ; else if ( R . numColumns ( ) != A . numColumns ( ) ) throw new IllegalArgumentException ( "R.numColumns() != A.numColumns()" ) ; // copy A values in Afact Afact . zero ( ) ; f...
Executes a QR factorization for the given matrix .
676
11
36,158
public void apply ( Matrix H , int column , int i1 , int i2 ) { double temp = c * H . get ( i1 , column ) + s * H . get ( i2 , column ) ; H . set ( i2 , column , - s * H . get ( i1 , column ) + c * H . get ( i2 , column ) ) ; H . set ( i1 , column , temp ) ; }
Applies the Givens rotation to two elements in a matrix column
94
14
36,159
public void apply ( Vector x , int i1 , int i2 ) { double temp = c * x . get ( i1 ) + s * x . get ( i2 ) ; x . set ( i2 , - s * x . get ( i1 ) + c * x . get ( i2 ) ) ; x . set ( i1 , temp ) ; }
Applies the Givens rotation to two elements of a vector
79
13
36,160
public static LQ factorize ( Matrix A ) { return new LQ ( A . numRows ( ) , A . numColumns ( ) ) . factor ( new DenseMatrix ( A ) ) ; }
Convenience method to compute a LQ decomposition
45
11
36,161
private void validate ( ) { if ( isDense ( ) && isPattern ( ) ) throw new IllegalArgumentException ( "Matrix cannot be dense with pattern storage" ) ; if ( isReal ( ) && isHermitian ( ) ) throw new IllegalArgumentException ( "Data cannot be real with hermitian symmetry" ) ; if ( ! isComplex ( ) && isHermitian ( ) ) thr...
Validates the representation
144
4
36,162
public static RQ factorize ( Matrix A ) { return new RQ ( A . numRows ( ) , A . numColumns ( ) ) . factor ( new DenseMatrix ( A ) ) ; }
Convenience method to compute an RQ decomposition
45
11
36,163
public void setRestart ( int restart ) { this . restart = restart ; if ( restart <= 0 ) throw new IllegalArgumentException ( "restart must be a positive integer" ) ; s = new DenseVector ( restart + 1 ) ; H = new DenseMatrix ( restart + 1 , restart ) ; rotation = new GivensRotation [ restart + 1 ] ; v = new Vector [ res...
Sets the restart parameter
122
5
36,164
private static void scatter ( SparseVector v , double [ ] z ) { int [ ] index = v . getIndex ( ) ; int used = v . getUsed ( ) ; double [ ] data = v . getData ( ) ; Arrays . fill ( z , 0 ) ; for ( int i = 0 ; i < used ; ++ i ) z [ index [ i ] ] = data [ i ] ; }
Copies the sparse vector into a dense array
88
9
36,165
private void gather ( double [ ] z , SparseVector v , double taui , int d ) { // Number of entries in the lower and upper part of the original matrix int nl = 0 , nu = 0 ; for ( VectorEntry e : v ) { if ( e . index ( ) < d ) nl ++ ; else if ( e . index ( ) > d ) nu ++ ; } v . zero ( ) ; // Entries in the L part of the ...
Copies the dense array back into the sparse vector applying a numerical dropping rule and keeping only a given number of entries
388
23
36,166
public void setEigenvalues ( double eigmin , double eigmax ) { this . eigmin = eigmin ; this . eigmax = eigmax ; if ( eigmin <= 0 ) throw new IllegalArgumentException ( "eigmin <= 0" ) ; if ( eigmax <= 0 ) throw new IllegalArgumentException ( "eigmax <= 0" ) ; if ( eigmin > eigmax ) throw new IllegalArgumentException (...
Sets the eigenvalue estimates .
115
8
36,167
private static void checkKhatriRaoArguments ( Matrix A , Matrix B ) { if ( A . numColumns ( ) != B . numColumns ( ) ) throw new IndexOutOfBoundsException ( "A.numColumns != B.numColumns (" + A . numColumns ( ) + " != " + B . numColumns ( ) + ")" ) ; }
Tests if the matrices have an equal number of columns .
85
13
36,168
public void printMatrixSize ( MatrixSize size , MatrixInfo info ) { format ( Locale . ENGLISH , "%10d %10d" , size . numRows ( ) , size . numColumns ( ) ) ; if ( info . isCoordinate ( ) ) format ( Locale . ENGLISH , " %19d" , size . numEntries ( ) ) ; println ( ) ; }
Prints the matrix size
88
5
36,169
public void printMatrixSize ( MatrixSize size ) { format ( Locale . ENGLISH , "%10d %10d %19d%n" , size . numRows ( ) , size . numColumns ( ) , size . numEntries ( ) ) ; }
Prints the matrix size . Assumes coordinate format
59
10
36,170
public void printVectorSize ( VectorSize size , VectorInfo info ) { format ( Locale . ENGLISH , "%10d" , size . size ( ) ) ; if ( info . isCoordinate ( ) ) format ( Locale . ENGLISH , " %19d" , size . numEntries ( ) ) ; println ( ) ; }
Prints the vector size
75
5
36,171
public void printVectorSize ( VectorSize size ) { format ( Locale . ENGLISH , "%10d %19d%n" , size . size ( ) , size . numEntries ( ) ) ; }
Prints the vector size . Assumes coordinate format
46
10
36,172
public void printArray ( double [ ] data ) { for ( int i = 0 ; i < data . length ; ++ i ) format ( Locale . ENGLISH , "% .12e%n" , data [ i ] ) ; }
Prints an array to the underlying stream . One entry per line .
51
14
36,173
public void printArray ( float [ ] dataR , float [ ] dataI ) { int size = dataR . length ; if ( size != dataI . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) format ( Locale . ENGLISH , "% .12e % .12e%n" , dataR [ i ] , dataI [ i ] ) ; }
Prints an array to the underlying stream . One entry per line . The first array specifies the real entries and the second is the imaginary entries
103
28
36,174
public void printCoordinate ( int [ ] index , long [ ] data , int offset ) { int size = index . length ; if ( size != data . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) format ( Locale . ENGLISH , "%10d %10d%n" , index [ i ] + offset , data...
Prints the coordinate format to the underlying stream . One index and entry on each line . The offset is added to the index typically this can transform from a 0 - based indicing to a 1 - based .
101
42
36,175
public void printCoordinate ( int [ ] index , float [ ] dataR , float [ ] dataI , int offset ) { int size = index . length ; if ( size != dataR . length || size != dataI . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) format ( Locale . ENGLIS...
Prints the coordinate format to the underlying stream . One index and entry on each line . The offset is added to each index typically this can transform from a 0 - based indicing to a 1 - based . The first float array specifies the real entries and the second is the imaginary entries
128
57
36,176
public void printCoordinate ( int [ ] row , int [ ] column , float [ ] dataR , float [ ] dataI , int offset ) { int size = row . length ; if ( size != column . length || size != dataR . length || size != dataI . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i ...
Prints the coordinate format to the underlying stream . One index pair and entry on each line . The offset is added to each index typically this can transform from a 0 - based indicing to a 1 - based . The first float array specifies the real entries and the second is the imaginary entries
149
58
36,177
public void printCoordinate ( int [ ] row , int [ ] column , long [ ] data , int offset ) { int size = row . length ; if ( size != column . length || size != data . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) format ( Locale . ENGLISH , "%1...
Prints the coordinate format to the underlying stream . One index pair and entry on each line . The offset is added to each index typically this can transform from a 0 - based indicing to a 1 - based .
122
43
36,178
public void printPattern ( int [ ] row , int [ ] column , int offset ) { int size = row . length ; if ( size != column . length ) throw new IllegalArgumentException ( "All arrays must be of the same size" ) ; for ( int i = 0 ; i < size ; ++ i ) format ( Locale . ENGLISH , "%10d %10d%n" , row [ i ] + offset , column [ i...
Prints the coordinates to the underlying stream . One index pair on each line . The offset is added to each index typically this can transform from a 0 - based indicing to a 1 - based .
102
40
36,179
public void printPattern ( int [ ] index , int offset ) { int size = index . length ; for ( int i = 0 ; i < size ; ++ i ) format ( Locale . ENGLISH , "%10d%n" , index [ i ] + offset ) ; }
Prints the coordinates to the underlying stream . One index on each line . The offset is added to each index typically this can transform from a 0 - based indicing to a 1 - based .
60
39
36,180
public void printCoordinate ( int [ ] row , int [ ] column , float [ ] dataR , float [ ] dataI ) { printCoordinate ( row , column , dataR , dataI , 0 ) ; }
Prints the coordinate format to the underlying stream . One index pair and entry on each line . The first double array specifies the real entries and the second is the imaginary entries
47
34
36,181
public static QL factorize ( Matrix A ) { return new QL ( A . numRows ( ) , A . numColumns ( ) ) . factor ( new DenseMatrix ( A ) ) ; }
Convenience method to compute a QL decomposition
45
11
36,182
private static int [ ] findDiagonalIndices ( CompRowMatrix A ) { int [ ] rowptr = A . getRowPointers ( ) ; int [ ] colind = A . getColumnIndices ( ) ; int [ ] diagIndices = new int [ A . numRows ( ) ] ; for ( int i = 0 ; i < A . numRows ( ) ; ++ i ) { diagIndices [ i ] = no . uib . cipr . matrix . sparse . Arrays . bin...
Finds the diagonal indices of the matrix
178
8
36,183
private List < Set < Integer > > findNodeNeighborhood ( CompRowMatrix A , int [ ] diagind , double eps ) { N = new ArrayList < Set < Integer > > ( A . numRows ( ) ) ; int [ ] rowptr = A . getRowPointers ( ) ; int [ ] colind = A . getColumnIndices ( ) ; double [ ] data = A . getData ( ) ; for ( int i = 0 ; i < A . numRo...
Finds the strongly coupled node neighborhoods
245
7
36,184
private static boolean [ ] createInitialR ( CompRowMatrix A ) { boolean [ ] R = new boolean [ A . numRows ( ) ] ; int [ ] rowptr = A . getRowPointers ( ) ; int [ ] colind = A . getColumnIndices ( ) ; double [ ] data = A . getData ( ) ; for ( int i = 0 ; i < A . numRows ( ) ; ++ i ) { boolean hasOffDiagonal = false ; fo...
Creates the initial R - set by including only the connected nodes
170
13
36,185
private List < Set < Integer > > createInitialAggregates ( List < Set < Integer > > N , boolean [ ] R ) { C = new ArrayList < Set < Integer > > ( ) ; for ( int i = 0 ; i < R . length ; ++ i ) { // Skip non-free nodes if ( ! R [ i ] ) continue ; // See if all nodes in the current N-set are free boolean free = true ; for...
Creates the initial aggregates
174
6
36,186
private static List < Set < Integer > > enlargeAggregates ( List < Set < Integer > > C , List < Set < Integer > > N , boolean [ ] R ) { // Contains the aggregates each node is coupled to List < List < Integer >> belong = new ArrayList < List < Integer > > ( R . length ) ; for ( int i = 0 ; i < R . length ; ++ i ) belon...
Enlarges the aggregates
396
6
36,187
private static List < Set < Integer > > createFinalAggregates ( List < Set < Integer > > C , List < Set < Integer > > N , boolean [ ] R ) { for ( int i = 0 ; i < R . length ; ++ i ) { // Skip non-free nodes if ( ! R [ i ] ) continue ; // Create new aggregate from the nodes in N[i] which are free Set < Integer > Cn = ne...
Creates final aggregates from the remaining unallocated nodes
163
12
36,188
public static SVD factorize ( Matrix A ) throws NotConvergedException { return new SVD ( A . numRows ( ) , A . numColumns ( ) ) . factor ( new DenseMatrix ( A ) ) ; }
Convenience method for computing a full SVD
51
10
36,189
public SVD factor ( DenseMatrix A ) throws NotConvergedException { if ( A . numRows ( ) != m ) throw new IllegalArgumentException ( "A.numRows() != m" ) ; else if ( A . numColumns ( ) != n ) throw new IllegalArgumentException ( "A.numColumns() != n" ) ; intW info = new intW ( 0 ) ; LAPACK . getInstance ( ) . dgesdd ( j...
Computes an SVD
244
5
36,190
public static int binarySearchGreater ( int [ ] index , int key , int begin , int end ) { return binarySearchInterval ( index , key , begin , end , true ) ; }
Searches for a key in a sorted array and returns an index to an element which is greater than or equal key .
41
25
36,191
public static int binarySearchSmaller ( int [ ] index , int key , int begin , int end ) { return binarySearchInterval ( index , key , begin , end , false ) ; }
Searches for a key in a sorted array and returns an index to an element which is smaller than or equal key .
41
25
36,192
public static int binarySearch ( int [ ] index , int key , int begin , int end ) { return java . util . Arrays . binarySearch ( index , begin , end , key ) ; }
Searches for a key in a subset of a sorted array .
42
14
36,193
public static int [ ] bandwidth ( int num , int [ ] ind ) { int [ ] nz = new int [ num ] ; for ( int i = 0 ; i < ind . length ; ++ i ) nz [ ind [ i ] ] ++ ; return nz ; }
Finds the number of repeated entries
59
7
36,194
public void setColumn ( int i , SparseVector x ) { if ( x . size ( ) != numRows ) throw new IllegalArgumentException ( "New column must be of the same size as existing column" ) ; colD [ i ] = x ; }
Sets the given column equal the passed vector
57
9
36,195
public void setRow ( int i , SparseVector x ) { if ( x . size ( ) != numColumns ) throw new IllegalArgumentException ( "New row must be of the same size as existing row" ) ; rowD [ i ] = x ; }
Sets the given row equal the passed vector
57
9
36,196
public double rcond ( Matrix A ) { if ( n != A . numRows ( ) ) throw new IllegalArgumentException ( "n != A.numRows()" ) ; if ( ! A . isSquare ( ) ) throw new IllegalArgumentException ( "!A.isSquare()" ) ; double anorm = A . norm ( Norm . One ) ; double [ ] work = new double [ 3 * n ] ; int [ ] iwork = new int [ n ] ; ...
Computes the reciprocal condition number
267
6
36,197
public static EVD factorize ( Matrix A ) throws NotConvergedException { return new EVD ( A . numRows ( ) ) . factor ( new DenseMatrix ( A ) ) ; }
Convenience method for computing the complete eigenvalue decomposition of the given matrix
43
17
36,198
public Matrix calcOrig ( ) { if ( ! Coordinates . equals ( getSource ( ) . getSize ( ) , getSize ( ) ) ) { throw new RuntimeException ( "Cannot change Matrix size. Use calc(Ret.NEW) or calc(Ret.LINK) instead." ) ; } long [ ] newCoordinates = new long [ position . length ] ; for ( long [ ] c : newContent . allCoordinate...
not the whole matrix
156
4
36,199
public Rectangle getCellRect ( int row , int column , boolean includeSpacing ) { Rectangle r = new Rectangle ( ) ; boolean valid = true ; if ( row < 0 ) { // y = height = 0; valid = false ; } else if ( row >= getRowCount ( ) ) { r . y = getHeight ( ) ; valid = false ; } else { r . height = getRowHeight ( row ) ; // r.y...
must be override otherwise it will iterate over all columns
478
11