Fix typos in package linalg; Fix norm_float64 in package rand

This commit is contained in:
gingerBill
2019-10-27 18:43:40 +00:00
parent 5e81fc72b9
commit a29a6d9285
2 changed files with 10 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package linalg
import "core:math"
import "intrinsics"
// Generic
@@ -78,9 +79,11 @@ transpose :: proc(a: $T/[$N][$M]$E) -> (m: ((M == N) ? T : [M][N]E)) {
return;
}
mul_matrix :: proc(a: $A/[$I][$J]$E, b: $B/[J][$K]E) -> (c: ((I == J && J == K && A == B) ? A : [I][K]E)) {
mul_matrix :: proc(a: $A/[$I][$J]$E, b: $B/[J][$K]E) -> (c: ((I == J && J == K && A == B) ? A : [I][K]E))
where !intrinsics.type_is_array(E),
intrinsics.type_is_numeric(E) {
for i in 0..<I {
for K in 0..<K {
for k in 0..<K {
for j in 0..<J {
c[i][k] += a[i][j] * b[j][k];
}
@@ -89,7 +92,9 @@ mul_matrix :: proc(a: $A/[$I][$J]$E, b: $B/[J][$K]E) -> (c: ((I == J && J == K &
return;
}
mul_matrix_vector :: proc(a: $A/[$I][$J]$E, b: $B/[I]E) -> (c: B) {
mul_matrix_vector :: proc(a: $A/[$I][$J]$E, b: $B/[I]E) -> (c: B)
where !intrinsics.type_is_array(E),
intrinsics.type_is_numeric(E) {
for i in 0..<I {
for j in 0..<J {
c[i] += a[i][j] * b[i];

View File

@@ -128,8 +128,8 @@ norm_float64 :: proc(r: ^Rand = global_rand_ptr) -> f64 {
if i == 0 {
for {
x = -math.log(float64(r)) * (1.0/ rn);
y := -math.log(float64(r));
x = -math.ln(float64(r)) * (1.0/ rn);
y := -math.ln(float64(r));
if y+y >= x*x {
break;
}