Skip to content

Commit

Permalink
core: add MulTransposed() function
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Oct 21, 2023
1 parent 0a0682d commit a573f59
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Your pull requests will be greatly appreciated!

- [ ] **core. Core functionality - WORK STARTED**
- [X] **Basic structures**
- [ ] **Operations on arrays - WORK STARTED**. The following functions still need implementation:
- [X] **Operations on arrays - WORK STARTED**. The following functions still need implementation:
- [X] [Mahalanobis](https://docs.opencv.org/master/d2/de8/group__core__array.html#ga4493aee129179459cbfc6064f051aa7d)
- [ ] [mulTransposed](https://docs.opencv.org/master/d2/de8/group__core__array.html#gadc4e49f8f7a155044e3be1b9e3b270ab)
- [X] [mulTransposed](https://docs.opencv.org/master/d2/de8/group__core__array.html#gadc4e49f8f7a155044e3be1b9e3b270ab)
- [X] [PCABackProject](https://docs.opencv.org/master/d2/de8/group__core__array.html#gab26049f30ee8e94f7d69d82c124faafc)
- [X] [PCACompute](https://docs.opencv.org/master/d2/de8/group__core__array.html#ga4e2073c7311f292a0648f04c37b73781)
- [X] [PCAProject](https://docs.opencv.org/master/d2/de8/group__core__array.html#ga6b9fbc7b3a99ebfd441bbec0a6bc4f88)
Expand Down
4 changes: 4 additions & 0 deletions core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ double Mat_Mahalanobis(Mat v1, Mat v2, Mat icovar) {
return cv::Mahalanobis(*v1, *v2, *icovar);
}

void MulTransposed(Mat src, Mat dest, bool ata) {
cv::mulTransposed(*src, *dest, ata);
}

void Mat_Max(Mat src1, Mat src2, Mat dst) {
cv::max(*src1, *src2, *dst);
}
Expand Down
8 changes: 8 additions & 0 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,14 @@ func Mahalanobis(v1, v2, icovar Mat) float64 {
return float64(C.Mat_Mahalanobis(v1.p, v2.p, icovar.p))
}

// MulTransposed calculates the product of a matrix and its transposition.
//
// For further details, please see:
// https://docs.opencv.org/4.x/d2/de8/group__core__array.html#gadc4e49f8f7a155044e3be1b9e3b270ab
func MulTransposed(src Mat, dest *Mat, ata bool) {
C.MulTransposed(src.p, dest.p, C.bool(ata))
}

// Max calculates per-element maximum of two arrays or an array and a scalar.
//
// For further details, please see:
Expand Down
1 change: 1 addition & 0 deletions core.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ double KMeansPoints(PointVector pts, int k, Mat bestLabels, TermCriteria criteri
void Mat_Log(Mat src, Mat dst);
void Mat_Magnitude(Mat x, Mat y, Mat magnitude);
double Mat_Mahalanobis(Mat v1, Mat v2, Mat icovar);
void MulTransposed(Mat src, Mat dest, bool ata);
void Mat_Max(Mat src1, Mat src2, Mat dst);
void Mat_MeanStdDev(Mat src, Mat dstMean, Mat dstStdDev);
void Mat_Merge(struct Mats mats, Mat dst);
Expand Down
13 changes: 13 additions & 0 deletions core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,19 @@ func TestMatMahalanobis(t *testing.T) {
}
}

func TestMulTransposed(t *testing.T) {
src := Eye(10, 10, MatTypeCV32FC1)
defer src.Close()

dst := NewMat()
defer dst.Close()

MulTransposed(src, &dst, true)
if dst.Empty() {
t.Error("MulTransposed dst should not be empty.")
}
}

func TestMatMax(t *testing.T) {
src1 := NewMatWithSize(4, 4, MatTypeCV32F)
defer src1.Close()
Expand Down

0 comments on commit a573f59

Please sign in to comment.