Created
August 29, 2017 20:57
-
-
Save h8nor/f1ca8aba16334018fd023a2900d920cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Special matrix R(i, j) (https://habrahabr.ru/post/336684/) | |
Option Explicit | |
Option Base 1 | |
'12345678901234567890123456789012345bopoh13@ya67890123456789012345678901234567890 | |
Function getR(p() As Double, q() As Double) As Double | |
Dim i As Integer, j As Integer | |
Dim Rx As Double, Ry As Double, Rz As Double | |
Dim R(5000, 5000) As Double, begin As Double | |
begin = Timer | |
For i = 1 To UBound(p, 1) | |
For j = 1 To UBound(q, 2) | |
Rx = p(i, 1) - q(1, j) | |
Ry = p(i, 2) - q(2, j) | |
Rz = p(i, 3) - q(3, j) | |
R(i, j) = 1 / (1 + Sqr(Rx * Rx + Ry * Ry + Rz * Rz)) | |
Next j, i: getR = (Timer - begin) * 1000 | |
End Function | |
Sub Time_spent_Testing() ' N = 5000 | |
Dim p(5000, 3) As Double, q(3, 5000) As Double, i As Integer | |
For i = 1 To 5000 | |
p(i, 1) = Rnd: p(i, 2) = Rnd: p(i, 3) = Rnd | |
q(1, i) = Rnd: q(2, i) = Rnd: q(3, i) = Rnd | |
Next i: Debug.Print Format(getR(p, q), "0 000 мс") ' 7 453 мс | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment