<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cardino Code in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387554#M161536</link>
    <description>&lt;P&gt;There is a signum function defined for complex variables in mathematics.&lt;/P&gt;
&lt;P&gt;It is defined as z/|z| for z not equal to 0, and as 0 for z = 0, z being a complex number.&lt;/P&gt;
&lt;P&gt;What do you expect the signum of &lt;EM&gt;i&lt;/EM&gt; to be? The signum of &lt;EM&gt;-i&amp;nbsp;&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;I wish you would spell Cardano's name the &lt;A href="https://en.wikipedia.org/wiki/Gerolamo_Cardano" target="_self"&gt;usual way&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2022 02:10:22 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2022-05-26T02:10:22Z</dc:date>
    <item>
      <title>Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386628#M161479</link>
      <description>&lt;P&gt;There is an interesting discussion on Cardino code evolving on the Fortran Discourse site.&amp;nbsp; FDs does not allow for zip files to be uploaded and I am loath to start a github point and waste days.&amp;nbsp; Plus most people are on both sites, and the important one is definitely.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the Intel Solution ( so far for Cardino).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also include the MNIST program from Milan C.&amp;nbsp; Interesting code, worth a look.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 16:36:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386628#M161479</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-23T16:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386712#M161489</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/41971"&gt;@mecej4&lt;/a&gt; pointed out I had a mistake in Cardino.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had assumed incorrectly that the function ** in complex numbers would return the correct answer for the one third root, it appears not to and one needs the work around&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;if((R%RE-SD%RE) .lt. 0.0D0) then
    T = -((abs(R-SD))**THIRDROOT)
    else
    T = (R - SD)**THIRDROOT
    end if&lt;/LI-CODE&gt;
&lt;P&gt;Where you check that the real part is negative - here the imaginary is zero and then the solution is trivially the 0ne third root of the positive number and then change the sign.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note I was just having some fun, there are a lot more checks to put in the code, I was just showing you could get it to work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 20:56:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386712#M161489</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-23T20:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386741#M161493</link>
      <description>&lt;P&gt;In order for MNIST to work in Intel Fortran properly as intended, we need to add RANDOM_SEED to teh published code, otherwise you are just repeating the same numbers over and over. Intel Fortran Random_number appears to take a constant from the computer if you do not use random_seed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The manual tells us:&amp;nbsp;&lt;SPAN&gt;the processor sets the seed for RANDOM_NUMBER to a processor-dependent value&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Any ideas what this processor dependent CONSTANT is?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 22:17:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386741#M161493</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-23T22:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386748#M161494</link>
      <description>&lt;P&gt;What you really want to call is RANDOM_INIT (.FALSE.,.FALSE.) This is the standard way of initializing RANDOM_NUMBER to have nonrepeatable sequences. (The second argument controls the behavior of RANDOM_NUMBER across coarray images.)&lt;/P&gt;
&lt;P&gt;What the specific constant value is isn't particularly important.&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 23:00:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1386748#M161494</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2022-05-23T23:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387015#M161503</link>
      <description>&lt;P&gt;I used RANDOM SEED and that has stopped the endless repition of the same numbers.&amp;nbsp; I will change to your method.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it is not important, merely asking why is a good scientific method.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-05-24 092728.png" style="width: 669px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/29861iB7D5781CAE0896AD/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="Screenshot 2022-05-24 092728.png" alt="Screenshot 2022-05-24 092728.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;        !if (this_image() == 1) &amp;amp;
        print '(a,i2,a,f5.2,a,/)', '               Epoch ', n, ' completed.  Accuracy of the analysis is : ', accuracy(net, validation_images, label_digits(validation_labels),2) * 100, ' %'

    end do epochs


    print '(//"               End of the analysis. "//)'
    print '(80("-"))'

    contains

    real function accuracy(net, x, y, PR)
    type(network), intent(in out) :: net
    real, intent(in) :: x(:,:), y(:,:)
    INTEGER, INTENT(IN) :: PR
    INTEGER, ALLOCATABLE :: k(:)
    INTEGER, ALLOCATABLE :: m(:)
    REAL, ALLOCATABLE :: P(:)
    REAL, ALLOCATABLE :: Q(:)
    integer :: i, good, n
    good = 0
    n = size(x, dim=2)
    do i = 1, n
        k = maxloc(y(:,i))
        p = y(k,i)
        m = maxloc(net % output(x(:,i)))
        Q = x(m,i)
        if (all(maxloc(net % output(x(:,i))) == maxloc(y(:,i)))) then
            good = good + 1

        else
            if(PR .eq. 2) then
            if(i .lt. 9900) then 
                write(*,*)i,k-1
            end if
            end if
        end if

    end do
    accuracy = real(good) / size(x, dim=2)
    end function accuracy

    end program Zeus

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code works ok without the print statement, but the line 34 causes this crash - I am lost?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;line 90 is in the program unit in Zeus, previously attached.&amp;nbsp; The function loops through 10000 numbers in two arrays to count same numbers.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 15:00:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387015#M161503</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-24T15:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387028#M161506</link>
      <description>&lt;P&gt;You call the function from a PRINT statement, and then have a PRINT statement in the function. Fortran doesn't allow you to start an I/O operation on a unit when one is already in progress on that unit. If you wanted to add this as a debugging statement, perhaps change it to a WRITE to unit 0 (STDERR).&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 15:25:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387028#M161506</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2022-05-24T15:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387425#M161528</link>
      <description>&lt;P&gt;Thanks for the answer.&amp;nbsp; I was intrigued that original developer used some interesting techniques from Fortran that are legal, but take a while to wrap your head around.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 16:26:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387425#M161528</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-25T16:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387427#M161529</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;T = (R - SD)**THIRDROOT&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If T, R and SD are complex, and the real components of R and SD are not zero, but the complex are zero, and R-SD &amp;lt; 0 on the number line, then the answer to this problem is purely real,&amp;nbsp; so if R-SD = -125 than the answer is -5, but Intel Fortran does not give this answer, it gives a complex number, with a non zero imaginary part..&amp;nbsp; This comes from the Cardino problem.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 16:33:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387427#M161529</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-25T16:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387495#M161533</link>
      <description>&lt;P&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/5442"&gt;@Steve_Lionel&lt;/a&gt;&amp;nbsp;, the problem of solving cubic equations was brought up on the Fortran discourse page. It is interesting to play with the code as I work on real stuff.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The support in Intel Fortran for complex functions, on the face of it appears a bit terse.&amp;nbsp; So for example the sign function is not defined as a function&amp;nbsp; in Intel for complex.&amp;nbsp; The interesting challenge is the variations in the definitions, although it would appear to have four defined pairs if you look at the logic of the problem.&amp;nbsp; Wikipedia and Wolfram offer opinions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am I missing something?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 21:56:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387495#M161533</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-05-25T21:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387496#M161534</link>
      <description>&lt;P&gt;The Fortran standard does not define SIGN on complex. As you note, it is not well-defined.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 21:59:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387496#M161534</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2022-05-25T21:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387554#M161536</link>
      <description>&lt;P&gt;There is a signum function defined for complex variables in mathematics.&lt;/P&gt;
&lt;P&gt;It is defined as z/|z| for z not equal to 0, and as 0 for z = 0, z being a complex number.&lt;/P&gt;
&lt;P&gt;What do you expect the signum of &lt;EM&gt;i&lt;/EM&gt; to be? The signum of &lt;EM&gt;-i&amp;nbsp;&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;I wish you would spell Cardano's name the &lt;A href="https://en.wikipedia.org/wiki/Gerolamo_Cardano" target="_self"&gt;usual way&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 02:10:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387554#M161536</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2022-05-26T02:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cardino Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387640#M161540</link>
      <description>&lt;P&gt;The way you would express the cubic root of a number x in Fortran or most other programming languages is by x**(1.0/3.0) (or pow(x, 1.0/3.0) or...). Note that the power is NOT 1/3, as it would be in mathematics, but a close approximation. And that is one of the problems: while with y = -5, y**3 gives -125, with x = 125 (positive, to avoid other problems), you cannot exactly get 5 via x**(1.0/3.0) - or if due to rounding it does happen to come out as 5 exactly, other values would lead to slight deviations from the mathematically correct value.&lt;/P&gt;
&lt;P&gt;The solution for a programming language is not to allow negative values for a power of fractional value. An alternative might be to define a power of 1/n as we have a power of n as well as of x (n integer, x real). But even that poses problems: (-1.0)**(1/4) is a complex number, whereas (-1.0)**(1/3) is -1.0.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 07:49:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cardino-Code/m-p/1387640#M161540</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2022-05-26T07:49:37Z</dc:date>
    </item>
  </channel>
</rss>

