Skip to content

Commit

Permalink
add an optimization to transpose() for row / column vector special case
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-zobel committed Jul 20, 2023
1 parent 6edc3fa commit 0ee5bd8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/main/java/net/jamu/matrix/ComplexMatrixDBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020, 2021 Stefan Zobel
* Copyright 2020, 2023 Stefan Zobel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1010,6 +1010,9 @@ public ComplexMatrixD conjugateTranspose() {
*/
@Override
public ComplexMatrixD transpose() {
if (rows == 1 || cols == 1) {
return create(cols, rows, Arrays.copyOf(a, a.length));
}
return trans(create(cols, rows));
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/jamu/matrix/ComplexMatrixFBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020, 2021 Stefan Zobel
* Copyright 2020, 2023 Stefan Zobel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1009,6 +1009,9 @@ public ComplexMatrixF conjugateTranspose() {
*/
@Override
public ComplexMatrixF transpose() {
if (rows == 1 || cols == 1) {
return create(cols, rows, Arrays.copyOf(a, a.length));
}
return trans(create(cols, rows));
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/jamu/matrix/MatrixDBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019, 2021 Stefan Zobel
* Copyright 2019, 2023 Stefan Zobel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -858,6 +858,9 @@ public ComplexMatrixD times(ComplexMatrixD B) {
*/
@Override
public MatrixD transpose() {
if (rows == 1 || cols == 1) {
return create(cols, rows, Arrays.copyOf(a, a.length));
}
return trans(create(cols, rows));
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/jamu/matrix/MatrixFBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019, 2021 Stefan Zobel
* Copyright 2019, 2023 Stefan Zobel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -858,6 +858,9 @@ public ComplexMatrixF times(ComplexMatrixF B) {
*/
@Override
public MatrixF transpose() {
if (rows == 1 || cols == 1) {
return create(cols, rows, Arrays.copyOf(a, a.length));
}
return trans(create(cols, rows));
}

Expand Down

0 comments on commit 0ee5bd8

Please sign in to comment.