From e4284da75ce83d21ed908a453ff4906fbab1580e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Thu, 2 Jul 2015 23:08:07 -0500 Subject: [PATCH 1/7] WIP: Document noteworthy unusual Julia features. Ref: https://github.com/JuliaLang/julia/issues/11966 Document unicode identifiers. [av skip] --- doc/manual/noteworthy-differences.rst | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index 0926b57c35ec6..fdad886f3ec2e 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -6,6 +6,44 @@ Noteworthy Differences from other Languages ******************************************* +Noteworthy unusual Julia features +--------------------------------- + +* Julia allows identifiers with complex unicode, for example you could represent the value of a chi-squared test with ``χ²``, ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility and ``∇²`` is used in electromagnetism for the third-order nonlinear susceptibility. All of these unicode symbols are valid Julia identifiers. + +.. doctest:: + + # x² instead of xx, x_squared, etc. + for x = 1:r; x² = x*x + for y = 1:r; y² = y*y + n = 4x² + y² + # do something with n + end + end + + # Lennard-Jones 12-6 potential energy + function lennard_jones(x, A, B) + x⁻² = x^-2 + x⁻⁶ = (x⁻²)^3 + x⁻¹² = (x⁻⁶)^2 + A*x⁻¹² - B*x⁻⁶ + end + + # Others + function expected!(ret, pixels, β) + μx, μy = β[1:2] + σ = β[3] + b² = β[4] + Na² = β[5] + for i in 1:length(pixels) + x, y = pixels[i] + ret[i] = Na²*twoDGauss(x, y, μx, μy, σ) + b² + end + ret + end + +But be wary... + Noteworthy differences from MATLAB ---------------------------------- From 926bd773ec44b8c32fd1d9b04f538ffadd2ad676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Fri, 3 Jul 2015 02:10:03 -0500 Subject: [PATCH 2/7] Update noteworthy-differences.rst [ci skip] Check whitespace latter when squashing commits. --- doc/manual/noteworthy-differences.rst | 39 ++++++++++----------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index fdad886f3ec2e..5a377de0cf5fe 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -6,42 +6,31 @@ Noteworthy Differences from other Languages ******************************************* -Noteworthy unusual Julia features +Noteworthy and unusual Julia features --------------------------------- -* Julia allows identifiers with complex unicode, for example you could represent the value of a chi-squared test with ``χ²``, ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility and ``∇²`` is used in electromagnetism for the third-order nonlinear susceptibility. All of these unicode symbols are valid Julia identifiers. +* Julia allows identifiers with complex Unicode, for example you could represent the value of a chi-squared test with ``χ²``, similarly ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility, another example is ``∇²`` which is the name of the Laplacian operator. All of these Unicode symbols are valid Julia identifiers. -.. doctest:: + - It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics. + + in order to compute: + + .. math:: + + A/x^12 - B/x^6 + + one can write: - # x² instead of xx, x_squared, etc. - for x = 1:r; x² = x*x - for y = 1:r; y² = y*y - n = 4x² + y² - # do something with n - end - end +.. doctest:: - # Lennard-Jones 12-6 potential energy - function lennard_jones(x, A, B) + "Lennard-Jones potential" + function lj(x, A, B) x⁻² = x^-2 x⁻⁶ = (x⁻²)^3 x⁻¹² = (x⁻⁶)^2 A*x⁻¹² - B*x⁻⁶ end - # Others - function expected!(ret, pixels, β) - μx, μy = β[1:2] - σ = β[3] - b² = β[4] - Na² = β[5] - for i in 1:length(pixels) - x, y = pixels[i] - ret[i] = Na²*twoDGauss(x, y, μx, μy, σ) + b² - end - ret - end - But be wary... Noteworthy differences from MATLAB From 86e6c5c14d0990af247e194d6c0150b19158c158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Fri, 3 Jul 2015 02:22:20 -0500 Subject: [PATCH 3/7] Update noteworthy-differences.rst [ci skip] --- doc/manual/noteworthy-differences.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index 5a377de0cf5fe..58f30116fb2bf 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -31,7 +31,9 @@ Noteworthy and unusual Julia features A*x⁻¹² - B*x⁻⁶ end -But be wary... +But be wary about referencing a global variable while thinking it was an operator applied to a local variable and updating a variable without remembering to update the cached value. + +* The ``/`` operator gives floating-point results for integer arguments, use ``div`` for truncating to an integer. Noteworthy differences from MATLAB ---------------------------------- From 768dcf31c103ee5fd9f4310594f46289f9deab7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Fri, 3 Jul 2015 02:24:19 -0500 Subject: [PATCH 4/7] Update noteworthy-differences.rst [ci skip] --- doc/manual/noteworthy-differences.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index 58f30116fb2bf..1878cea6a14f2 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -21,17 +21,17 @@ Noteworthy and unusual Julia features one can write: -.. doctest:: + .. doctest:: - "Lennard-Jones potential" - function lj(x, A, B) - x⁻² = x^-2 - x⁻⁶ = (x⁻²)^3 - x⁻¹² = (x⁻⁶)^2 - A*x⁻¹² - B*x⁻⁶ - end + "Lennard-Jones potential" + function lj(x, A, B) + x⁻² = x^-2 + x⁻⁶ = (x⁻²)^3 + x⁻¹² = (x⁻⁶)^2 + A*x⁻¹² - B*x⁻⁶ + end -But be wary about referencing a global variable while thinking it was an operator applied to a local variable and updating a variable without remembering to update the cached value. + But be wary about referencing a global variable while thinking it was an operator applied to a local variable and updating a variable without remembering to update the cached value. * The ``/`` operator gives floating-point results for integer arguments, use ``div`` for truncating to an integer. From 98440f55b8ce55912538bfd389123714b419d89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Fri, 3 Jul 2015 02:25:45 -0500 Subject: [PATCH 5/7] Update noteworthy-differences.rst [ci skip] --- doc/manual/noteworthy-differences.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index 1878cea6a14f2..053a9eaf5661a 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -11,7 +11,7 @@ Noteworthy and unusual Julia features * Julia allows identifiers with complex Unicode, for example you could represent the value of a chi-squared test with ``χ²``, similarly ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility, another example is ``∇²`` which is the name of the Laplacian operator. All of these Unicode symbols are valid Julia identifiers. - - It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics. + It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics. in order to compute: From dde34b91963d0b8bd44e8475275f6072ed707bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Fri, 3 Jul 2015 02:32:13 -0500 Subject: [PATCH 6/7] Update noteworthy-differences.rst [ci skip] --- doc/manual/noteworthy-differences.rst | 35 +++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index 053a9eaf5661a..4dddc09a2f146 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -9,29 +9,32 @@ Noteworthy Differences from other Languages Noteworthy and unusual Julia features --------------------------------- -* Julia allows identifiers with complex Unicode, for example you could represent the value of a chi-squared test with ``χ²``, similarly ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility, another example is ``∇²`` which is the name of the Laplacian operator. All of these Unicode symbols are valid Julia identifiers. +* Julia allows identifiers with complex Unicode, for example you could represent the value of a chi-squared test with ``χ²``, + similarly ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility, another example is ``∇²`` + which is the name of the Laplacian operator. All of these Unicode symbols are valid Julia identifiers. - It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics. + It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics, in order to compute: - in order to compute: + .. math:: - .. math:: - - A/x^12 - B/x^6 + A/x^12 - B/x^6 - one can write: + one can write: - .. doctest:: + .. doctest:: - "Lennard-Jones potential" - function lj(x, A, B) - x⁻² = x^-2 - x⁻⁶ = (x⁻²)^3 - x⁻¹² = (x⁻⁶)^2 - A*x⁻¹² - B*x⁻⁶ - end + "Lennard-Jones potential" + function lj(x, A, B) + x⁻² = x^-2 + x⁻⁶ = (x⁻²)^3 + x⁻¹² = (x⁻⁶)^2 + A*x⁻¹² - B*x⁻⁶ + end - But be wary about referencing a global variable while thinking it was an operator applied to a local variable and updating a variable without remembering to update the cached value. + .. note:: + + Be wary about referencing a global variable while thinking it was an operator applied to a local variable and updating a + variable without remembering to update the cached value. * The ``/`` operator gives floating-point results for integer arguments, use ``div`` for truncating to an integer. From 86b53ca3a69587d386859915fb072b309302159c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Venegas=20Castell=C3=B3?= Date: Fri, 3 Jul 2015 02:33:15 -0500 Subject: [PATCH 7/7] Update noteworthy-differences.rst [ci skip] --- doc/manual/noteworthy-differences.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index 4dddc09a2f146..ce1d88f7e9fbf 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -13,7 +13,8 @@ Noteworthy and unusual Julia features similarly ``χ⁽³⁾`` is used in electromagnetism for the third-order nonlinear susceptibility, another example is ``∇²`` which is the name of the Laplacian operator. All of these Unicode symbols are valid Julia identifiers. - It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics, in order to compute: + It can also be useful for caching powers of ``x`` to ensure that intermediate products are reused optimally in time-critical code. + A classic example is in computing the [Lennard-Jones 12-6 potential energy](https://en.wikipedia.org/wiki/Lennard-Jones_potential) in computational chemistry and physics, in order to compute: .. math::