Skip to content

Commit

Permalink
Add Matrix.getTransposedToAddress()/setTransposedFromAddress() (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed Mar 11, 2023
1 parent dccd432 commit 4072dff
Show file tree
Hide file tree
Showing 21 changed files with 474 additions and 16 deletions.
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix2d.java
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,12 @@ public Matrix2dc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix2dc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

public double[] get(double[] arr, int offset) {
Expand Down Expand Up @@ -874,6 +880,24 @@ public Matrix2d setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return this;
}
/**
* Set the values of this matrix by reading 4 double values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix2d setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return this;
}
//#endif

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix2dc.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,18 @@ public interface Matrix2dc {
* @return this
*/
Matrix2dc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix2dc getTransposedToAddress(long address);
//#endif

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix2f.java
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ public Matrix2fc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix2fc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

public float[] get(float[] arr, int offset) {
Expand Down Expand Up @@ -705,6 +711,24 @@ public Matrix2f setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return this;
}
/**
* Set the values of this matrix by reading 4 float values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix2f setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return this;
}
//#endif

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix2fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@ public interface Matrix2fc {
* @return this
*/
Matrix2fc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix2fc getTransposedToAddress(long address);
//#endif

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,12 @@ public Matrix3dc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix3dc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

public double[] get(double[] arr, int offset) {
Expand Down Expand Up @@ -1388,6 +1394,24 @@ public Matrix3d setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return this;
}
/**
* Set the values of this matrix by reading 9 double values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix3d setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return this;
}
//#endif

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix3dc.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,18 @@ public interface Matrix3dc {
* @return this
*/
Matrix3dc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix3dc getTransposedToAddress(long address);
//#endif

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix3f.java
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,12 @@ public Matrix3fc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix3fc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

public float[] get(float[] arr, int offset) {
Expand Down Expand Up @@ -1094,6 +1100,24 @@ public Matrix3f setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return this;
}
/**
* Set the values of this matrix by reading 9 float values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix3f setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return this;
}
//#endif

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix3fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,18 @@ public interface Matrix3fc {
* @return this
*/
Matrix3fc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix3fc getTransposedToAddress(long address);
//#endif

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix3x2d.java
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,12 @@ public Matrix3x2dc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix3x2dc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

/**
Expand Down Expand Up @@ -1319,6 +1325,24 @@ public Matrix3x2d setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return this;
}
/**
* Set the values of this matrix by reading 6 double values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix3x2d setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return this;
}
//#endif

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix3x2dc.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,18 @@ public interface Matrix3x2dc {
* @return this
*/
Matrix3x2dc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix3x2dc getTransposedToAddress(long address);
//#endif

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix3x2f.java
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,12 @@ public Matrix3x2fc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix3x2fc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

/**
Expand Down Expand Up @@ -1217,6 +1223,24 @@ public Matrix3x2f setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return this;
}
/**
* Set the values of this matrix by reading 6 float values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix3x2f setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return this;
}
//#endif

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix3x2fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,18 @@ public interface Matrix3x2fc {
* @return this
*/
Matrix3x2fc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix3x2fc getTransposedToAddress(long address);
//#endif

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/joml/Matrix4d.java
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,24 @@ public Matrix4d setFromAddress(long address) {
MemUtil.MemUtilUnsafe.get(this, address);
return determineProperties();
}
/**
* Set the values of this matrix by reading 16 double values from off-heap memory in row-major order,
* starting at the given address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap memory address to read the matrix values from in row-major order
* @return this
*/
public Matrix4d setTransposedFromAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.getTransposed(this, address);
return determineProperties();
}
//#endif

/**
Expand Down Expand Up @@ -3489,6 +3507,12 @@ public Matrix4dc getToAddress(long address) {
MemUtil.MemUtilUnsafe.put(this, address);
return this;
}
public Matrix4dc getTransposedToAddress(long address) {
if (Options.NO_UNSAFE)
throw new UnsupportedOperationException("Not supported when using joml.nounsafe");
MemUtil.MemUtilUnsafe.putTransposed(this, address);
return this;
}
//#endif

public double[] get(double[] dest, int offset) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/joml/Matrix4dc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,18 @@ Matrix4d mul3x3(
* @return this
*/
Matrix4dc getToAddress(long address);
/**
* Store this matrix in row-major order at the given off-heap address.
* <p>
* This method will throw an {@link UnsupportedOperationException} when JOML is used with `-Djoml.nounsafe`.
* <p>
* <em>This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.</em>
*
* @param address
* the off-heap address where to store this matrix
* @return this
*/
Matrix4dc getTransposedToAddress(long address);
//#endif

/**
Expand Down
Loading

0 comments on commit 4072dff

Please sign in to comment.