Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

HW7 #15

wants to merge 10 commits into from

Conversation

GrigorySmirnovSpb
Copy link
Owner

Написал 7 домашку. Здесь представлена библиотека, которая преобразует матрицы в деревья квадрантов и из них обратно. Также написаны функции умножения, map и map2. В дополнение к ним были написаны тесты для этих функций.


module Matrix =
type Nothing =
| Empty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это что?

| Empty

type QuadMatrix<'T> =
| Leaf of 'T * int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем тут int?

then 0.0
else max (Math.Log2(Array2D.length1 inmatr)) (Math.Log2(Array2D.length2 inmatr))

let isSizeFalse = not (logSize = float (int logSize))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Загадочное название функции

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему же загадочное? Я делаю квадратную матрицу, для неё нужен квадратный размер со стороной степени двойки. Поэтому и назвал так, Неправильный ли размер

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда уж correct а не false хотя бы.


let rec multiplyMatrix qTree1 qTree2 =
match qTree1, qTree2 with
| Leaf(value1, size1), Leaf(value2, size2) -> Leaf(value1 * value2, size1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Удивительно. Не должно работать.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Видимо, таки мало тестов.

@GrigorySmirnovSpb GrigorySmirnovSpb requested a review from gsvgit March 2, 2025 13:54

let rec multiplyMatrix qtree1 size1 qtree2 size2 =
match qtree1, qtree2 with
| Leaf(value1), Leaf(value2) -> Leaf(value1 * value2 * size1)
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Правдв ли, что типичные заклинания нельзя вынести в отдельную функцию?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я вроде бы вынес, разве нет, сейчас посмотрю

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вопрос, а про какие именно заклинания идёт речь?

@GrigorySmirnovSpb GrigorySmirnovSpb requested a review from gsvgit March 4, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants