Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

how to put the last value of a matrix as first value and vice versa

This example can be helpful for you

I commented the code so it will be quite easy to understand

public class MatrixExample {

    private static int[][] reverse(int[][]
        int row=matrix.length;
        int column=matrix[0].length; //we have for
shure this element, his length is the number of
        int to_return[][] = new int[row][column];
//this is a matrix of the same dimention of the
        //the indexes that will cicle the row and
the column of the new matrix
        int new_row=0; 
        int new_column=0;
        for(int i=row-1;i>-1;i--){ //this will
cile the rows from the last to thee first
            for(int j=column-1;j>-1;j--){ 
//this will cicle the colums from the last to the
        return to_return;
    public static void main(String[] args) {
        int matrix[][] = {{ 1, 2, 3},
                        {4, 5, 6},
                        {7, 8, 9},

        int[][] new_matrix = reverse(matrix);

        for(int i=0;i<new_matrix.length;i++){
System.out.print(new_matrix[i][j]+" ");


Categories : Java

Related to : how to put the last value of a matrix as first value and vice versa
Eigen sparse matrix multiplications seem to compute full matrix
Basically, the document is sightly confusing for me at least. the way to do it is simply: SpMat mat_3 = mat_1 * mat_2 No dense matrix is created along the way. Eigen rocks!

Categories : C++
python - how to compute correlation-matrix with nans in data-matrix
You can convert all nan values to zeros using np.nan_to_num() and then proceed further. Demo: >>> data array([[ 5.1, 3.5, 1.4, 0.2], [ 4.9, 3. , nan, 0.2], [ 4.7, 3.2, 1.3, nan], [ nan, 3.1, 1.5, 0.2]]) >>> np.cov(data.T) array([[ nan, nan, nan, nan], [ nan, 0.04666667, nan, nan],

Categories : Python
How can I get the amound of seconds from a NSDate ("hh:mm:ss") and vice versa
You could have a place holder date e.g. 00:00:00 and then use the NSDate function timeIntervalSinceDate: to get the seconds. Converting back again you could use the dateWithTimeInterval: method. Obviously both these dates would have to be the same year month and day and you could use any arbitrary values for these as long as they are the same.

Categories : Objective C
matrix inside matrix when multiplying symbolic matrices
The problem seems to be the K = C2^(16/57). Taking the root of a matrix is not trivial and solutions don't always exist. That's why MATLAB cannot resolve this expression. Try for example: A = syms('A',[3,3]); % create 3x3 symbolic matrix B = A^(1/3); % calculate the 3rd root of A The result will be ans = matrix([[a1_1, a1_2, a1_3], [a2_1, a2_2, a2_3], [a3_1, a3_2, a3_3]])^(1/3)

Categories : Matlab
Filling up a matrix with computed values of another matrix
Assuming that the block of columns are based on the first two characters, i.e. A1, A2, we can split this into different blocks by using substr to extract the first two characters from the column names and use this as index to split. Then, we can either use apply with range and diff to get the result or use pmax and pmin. indx <- substr(colnames(df), 1,2) If the grouping is not based on t

Categories : R
Recently Add
Redirecting the output directory of 'mvn package' or 'mvn compile' command
No suitable constructor found for ProductoExtranjero
java Composite design pattern(Directory &File)
Java JTree's ui refresh after removing node from parent
First REST Spring application
How to cancel Indexing of a Solr document using Update Request Processor
PowerMock - Mock a Singleton with a Private Constructor
Calling a Postgres stored function SQL error
Where to store Morphlines Java custom command class?
Generic repository using map
How can I scroll a ScrolledComposited in Eclipse SWT Design view?
2 Frames/layout in 1 Activity
Writing a switch differently
Next button opens another activity when its reaches the array limit
Is EclipseLink MOXy capable of applying JSR-303 Bean Validation when unmarshalling XML to object?
Why my jdk can't work,and before the java_home, there is a space that is not from me
How to add List of objects in a Map
How to make notepad++ function like regular notepad in cmd?
Cell renderer and the lost focus
how can I implement iterable for LinkedList>
Disable Androids image-crunch in eclipse (run as) builds
java 8 lambda != myMap.size() after merging myMap
Issue with Calendar calculation that spans 2 calendar years
JSF 2.0 Spring bean injection
Java Regex ReplaceAll with grouping
Getting any word and last word using sed
Clicking on link on JEditorPane throws IOException
printing out difference of two arrays
Spring Bean Alias in JavaConfig
Using Factory Method to Create Generics
© Copyright 2017 Publishing Limited. All rights reserved.