Closed 080993 closed 6 years ago
Ок, понял, по-поводу последнего - видимо не затёр старый тест, который уже был запушен.
2018-02-18 21:48 GMT+07:00 Ilya notifications@github.com:
@9il requested changes on this pull request. In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168917432 : @@ -1891,6 +1914,12 @@ auto choleskySolve(Flag!"allowDestroy" allowDestroy = No.allowDestroy, (Slice!(Canonical, [2], IteratorC) c, Slice!(kindB, n, IteratorB) b, char uplo) +in +{ assert(c.length!0 == c.length!1, "matrix must be squared"); assert(c.length!1 == b.length!0, "num column a must be equally num rows b"); Ищите правильный перевод In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953517 : } } +void setBuffer(T)(ulong length) неправильно. Буфер общий для всех типов. В стандартной библиотеке есть функция соответствующая без цикла In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953542 : import mir.ndslice.algorithm: equal; assert(equal!((a, b) => fabs(a - b) < 1e-12)(B, A)); +} +///LUResult consist lu factorization. +struct LUResult(T) +{ ///Matrix in witch lower triangular is L part of factorization ///(diagonal elements of L are not stored), upper triangular ///is U part of factorization. Slice!(Canonical, [2], T*) lut; ///The pivot indices, for 1 <= i <= min(M,N), row i of the matrix ///was interchanged with row ipiv(i). Slice!(Contiguous, [1], lapackint*) ipiv; ///L part of the factorization. auto l() @property https://github.com/property, уже несколько раз писал. In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953638 : + +///LUResult consist lu factorization. +struct LUResult(T) +{ ///Matrix in witch lower triangular is L part of factorization ///(diagonal elements of L are not stored), upper triangular ///is U part of factorization. Slice!(Canonical, [2], T*) lut; ///The pivot indices, for 1 <= i <= min(M,N), row i of the matrix ///was interchanged with row ipiv(i). Slice!(Contiguous, [1], lapackint*) ipiv; ///L part of the factorization. auto l() { auto l = uninitSlice!T(lut.length!1, min(lut.length!0, lut.length!1)); foreach(i;0..l.length!0) Используйте новые функции в mir-algorithm v0.8.0, eachLower, eachUpper. Обнуляйте аставшуюся часть матрицы. Есть топология diagonal. if в цикле это плохо In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953681 : SliceKind kind, Iterator) (Slice!(kind, [2], Iterator) a) +{ alias T = BlasType!Iterator; auto ipiv = uninitSlice!lapackint(min(a.length!0, a.length!1)); auto b = a.transposed; if(allowDestroy && b._stride!1 == 1) { auto m = b.assumeCanonical; getrf(m, ipiv); return LUResult!T(m, ipiv); } else { auto m = a.transposed.as!T.slice.canonical; Используйте в таких простых случаях выражение ? : вместо внешнего if In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953701 : { auto m = b.assumeCanonical; getrf(m, ipiv); return LUResult!T(m, ipiv); } else { auto m = a.transposed.as!T.slice.canonical; getrf(m, ipiv); return LUResult!T(m, ipiv); } +} +/++ +Solves a system of linear equations \A * X = B or A*T X = B Про бек слешы для выражений в комменьариях я тоже говорил In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953822 : [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] .sliced(5, 5) .as!double.slice .universal; auto C = B.slice; auto LU = A.luDecomp(); auto m = luSolve!(Yes.allowDestroy)(LU.lut, LU.ipiv, B.transposed); auto m2 = LU.solve(C); import mir.ndslice.algorithm: equal; assert(equal!((a, b) => fabs(a - b) < 1e-12)(mtimes(A, m), C)); вместо этой лямбды везде просто approxEqual из стандартной библиотеки. In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953848 : 21, 48, 72, 21, 88 ] .sliced(5, 5) .as!double.slice .universal; auto B = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] .sliced(5, 5) .as!double.slice .canonical; auto LU = A.luDecomp(); auto m = solve(LU, B); Что это за вызов? Что за solve? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kaleidicassociates/lubeck/pull/5#pullrequestreview-97369968, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah8NlEL0mY3cyhPwrv8ZoTf7U3JHSSeHks5tWDhAgaJpZM4R1dGW .
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168917432 :
@@ -1891,6 +1914,12 @@ auto choleskySolve(Flag!"allowDestroy" allowDestroy = No.allowDestroy, (Slice!(Canonical, [2], IteratorC) c, Slice!(kindB, n, IteratorB) b, char uplo) +in +{ assert(c.length!0 == c.length!1, "matrix must be squared"); assert(c.length!1 == b.length!0, "num column a must be equally num rows b");
@@ -1891,6 +1914,12 @@ auto choleskySolve(Flag!"allowDestroy" allowDestroy = No.allowDestroy, (Slice!(Canonical, [2], IteratorC) c, Slice!(kindB, n, IteratorB) b, char uplo) +in +{
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953517 :
} }
}
+void setBuffer(T)(ulong length)
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953542 :
import mir.ndslice.algorithm: equal; assert(equal!((a, b) => fabs(a - b) < 1e-12)(B, A)); +} +///LUResult consist lu factorization. +struct LUResult(T) +{ ///Matrix in witch lower triangular is L part of factorization ///(diagonal elements of L are not stored), upper triangular ///is U part of factorization. Slice!(Canonical, [2], T*) lut; ///The pivot indices, for 1 <= i <= min(M,N), row i of the matrix ///was interchanged with row ipiv(i). Slice!(Contiguous, [1], lapackint*) ipiv; ///L part of the factorization. auto l()
+///LUResult consist lu factorization. +struct LUResult(T) +{
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953638 :
+ +///LUResult consist lu factorization. +struct LUResult(T) +{ ///Matrix in witch lower triangular is L part of factorization ///(diagonal elements of L are not stored), upper triangular ///is U part of factorization. Slice!(Canonical, [2], T*) lut; ///The pivot indices, for 1 <= i <= min(M,N), row i of the matrix ///was interchanged with row ipiv(i). Slice!(Contiguous, [1], lapackint*) ipiv; ///L part of the factorization. auto l() { auto l = uninitSlice!T(lut.length!1, min(lut.length!0, lut.length!1)); foreach(i;0..l.length!0)
+ +///LUResult consist lu factorization. +struct LUResult(T) +{
Используйте новые функции в mir-algorithm v0.8.0, eachLower, eachUpper.
Обнуляйте аставшуюся часть матрицы.
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953681 :
SliceKind kind, Iterator) (Slice!(kind, [2], Iterator) a) +{ alias T = BlasType!Iterator; auto ipiv = uninitSlice!lapackint(min(a.length!0, a.length!1)); auto b = a.transposed; if(allowDestroy && b._stride!1 == 1) { auto m = b.assumeCanonical; getrf(m, ipiv); return LUResult!T(m, ipiv); } else { auto m = a.transposed.as!T.slice.canonical;
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953701 :
{ auto m = b.assumeCanonical; getrf(m, ipiv); return LUResult!T(m, ipiv); } else { auto m = a.transposed.as!T.slice.canonical; getrf(m, ipiv); return LUResult!T(m, ipiv); } +} +/++ +Solves a system of linear equations \A * X = B or A*T X = B
+/++ +Solves a system of linear equations
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953822 :
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] .sliced(5, 5) .as!double.slice .universal; auto C = B.slice; auto LU = A.luDecomp(); auto m = luSolve!(Yes.allowDestroy)(LU.lut, LU.ipiv, B.transposed); auto m2 = LU.solve(C); import mir.ndslice.algorithm: equal; assert(equal!((a, b) => fabs(a - b) < 1e-12)(mtimes(A, m), C));
In source/lubeck.d https://github.com/kaleidicassociates/lubeck/pull/5#discussion_r168953848 :
21, 48, 72, 21, 88 ] .sliced(5, 5) .as!double.slice .universal; auto B = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] .sliced(5, 5) .as!double.slice .canonical; auto LU = A.luDecomp(); auto m = solve(LU, B);
Что это за вызов? Что за solve?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kaleidicassociates/lubeck/pull/5#pullrequestreview-97369968, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah8NlEL0mY3cyhPwrv8ZoTf7U3JHSSeHks5tWDhAgaJpZM4R1dGW .
Ок, понял, по-поводу последнего - видимо не затёр старый тест, который уже был запушен.
2018-02-18 21:48 GMT+07:00 Ilya notifications@github.com: