-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HW7 #15
base: main
Are you sure you want to change the base?
HW7 #15
Conversation
src/LibHw7/Library.fs
Outdated
|
||
module Matrix = | ||
type Nothing = | ||
| Empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А это что?
src/LibHw7/Library.fs
Outdated
| Empty | ||
|
||
type QuadMatrix<'T> = | ||
| Leaf of 'T * int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем тут int
?
src/LibHw7/Library.fs
Outdated
then 0.0 | ||
else max (Math.Log2(Array2D.length1 inmatr)) (Math.Log2(Array2D.length2 inmatr)) | ||
|
||
let isSizeFalse = not (logSize = float (int logSize)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Загадочное название функции
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему же загадочное? Я делаю квадратную матрицу, для неё нужен квадратный размер со стороной степени двойки. Поэтому и назвал так, Неправильный ли размер
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тогда уж correct
а не false
хотя бы.
src/LibHw7/Library.fs
Outdated
|
||
let rec multiplyMatrix qTree1 qTree2 = | ||
match qTree1, qTree2 with | ||
| Leaf(value1, size1), Leaf(value2, size2) -> Leaf(value1 * value2, size1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удивительно. Не должно работать.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Видимо, таки мало тестов.
src/LibHw7/Library.fs
Outdated
|
||
let rec multiplyMatrix qtree1 size1 qtree2 size2 = | ||
match qtree1, qtree2 with | ||
| Leaf(value1), Leaf(value2) -> Leaf(value1 * value2 * size1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мммм. Правда ли, что я смогу работать с матрицами произвольных типов?
Test/TestsHw7.fs
Outdated
let matr2 = Gen.sample 1 (PropertyTest.matrixGenerator (int size) (int size) (Gen.choose (-100000, 100000))) | ||
let matr11d = PropertyTest.toArray matr1.[0] | ||
let matr21d = PropertyTest.toArray matr2.[0] | ||
let expmatr = Array.map2 (fun x y -> x + y) matr11d matr21d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Правдв ли, что типичные заклинания нельзя вынести в отдельную функцию?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я вроде бы вынес, разве нет, сейчас посмотрю
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вопрос, а про какие именно заклинания идёт речь?
Написал 7 домашку. Здесь представлена библиотека, которая преобразует матрицы в деревья квадрантов и из них обратно. Также написаны функции умножения, map и map2. В дополнение к ним были написаны тесты для этих функций.