Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Algorithm Complexity

Algorithm Complexity

Scheduled Pinned Locked Moved The Lounge
algorithmscsharphtmlcomtools
72 Posts 30 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Bassam Abdul Baki

    Is there a known method for comparing different algorithms? What we're looking for is a way to assign weights to different operands (+,-,*,/) and functions (sin,cos,tan,cot,sqrt) and see how they compare to each other. Is anyone aware of such a method? Thanks


    "Religion is assurance in numbers." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

    N Offline
    N Offline
    NormDroid
    wrote on last edited by
    #9

    Interesting, if you do find an article for sheet with the 'weights' of each operator/function I'd be interested to know. Surely someone, somewhere must of done this kind of thing.

    WPF - Imagineers Wanted Follow your nose using DoubleAnimationUsingPath

    B 1 Reply Last reply
    0
    • B Bassam Abdul Baki

      Is there a known method for comparing different algorithms? What we're looking for is a way to assign weights to different operands (+,-,*,/) and functions (sin,cos,tan,cot,sqrt) and see how they compare to each other. Is anyone aware of such a method? Thanks


      "Religion is assurance in numbers." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #10

      If you want to know the number of cycles you could check the chip documentation to determine how many micro cycles a given op will use. With the relatively simple complexity of those algorithms I doubt even big analysis will help. I believe all of those functions use look up tables and identities.


      Need a C# Consultant? I'm available.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

      B 1 Reply Last reply
      0
      • R Rama Krishna Vavilala

        Are there any decisons or loops or just formulas?

        Co-Author ASP.NET AJAX in Action

        B Offline
        B Offline
        Bassam Abdul Baki
        wrote on last edited by
        #11

        Just formulas.


        "There are II kinds of people in the world, those who understand binary and those who understand Roman numerals." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

        R 1 Reply Last reply
        0
        • N NormDroid

          Interesting, if you do find an article for sheet with the 'weights' of each operator/function I'd be interested to know. Surely someone, somewhere must of done this kind of thing.

          WPF - Imagineers Wanted Follow your nose using DoubleAnimationUsingPath

          B Offline
          B Offline
          Bassam Abdul Baki
          wrote on last edited by
          #12

          I was hoping so. And like I told Rama, it's just for formulas.


          "Patriotism is your conviction that this country is superior to all other countries because you were born in it." - George Bernard Shaw Web - Blog - RSS - Math - LinkedIn - BM

          1 Reply Last reply
          0
          • E El Corazon

            Bassam Abdul-Baki wrote:

            Is anyone aware of such a method?

            I generally use a profiler. if you really want a number, test it. Call 1 MILLION calls of a given operation, time it, come up wth a numerical scale for each operand based on the time it takes to call each operation. Now you have a good number.

            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

            B Offline
            B Offline
            Bassam Abdul Baki
            wrote on last edited by
            #13

            That was my initial suggestion, but they wanted something algebraic and not computed. Go figure.


            "Dissent is the highest form of patriotism." - Thomas Jefferson Web - Blog - RSS - Math - LinkedIn - BM

            E 1 Reply Last reply
            0
            • E Ennis Ray Lynch Jr

              If you want to know the number of cycles you could check the chip documentation to determine how many micro cycles a given op will use. With the relatively simple complexity of those algorithms I doubt even big analysis will help. I believe all of those functions use look up tables and identities.


              Need a C# Consultant? I'm available.
              Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

              B Offline
              B Offline
              Bassam Abdul Baki
              wrote on last edited by
              #14

              Unfortunately, they wanted something quick and dirty since this was added to the proposal at the last minute.


              "Patriotism is your conviction that this country is superior to all other countries because you were born in it." - George Bernard Shaw Web - Blog - RSS - Math - LinkedIn - BM

              1 Reply Last reply
              0
              • M Maximilien

                You need to compute the number of operations that each algorithm is doing depending on the size of the inputs. (edit) usually, all binary operations are constant in time. for example : 1+1 is O(1) loops are linear in complexity : j = 0; for ( i = 0; i < n; i++ ) { j++;} is O(n) and so on and so forth.


                Maximilien Lincourt Your Head A Splode - Strong Bad

                B Offline
                B Offline
                Bassam Abdul Baki
                wrote on last edited by
                #15

                No loops, just equations, with a couple of sin/cos/tan and sqrts.


                "Marge, don't discourage the boy! Weasling out of things is important to learn. It's what separates us from the animals! Except the weasel." - Homer Simpson Web - Blog - RSS - Math - LinkedIn - BM

                M 1 Reply Last reply
                0
                • B Bassam Abdul Baki

                  Just formulas.


                  "There are II kinds of people in the world, those who understand binary and those who understand Roman numerals." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                  R Offline
                  R Offline
                  Rama Krishna Vavilala
                  wrote on last edited by
                  #16

                  Can you give an example or two?

                  Co-Author ASP.NET AJAX in Action

                  B 1 Reply Last reply
                  0
                  • B Bassam Abdul Baki

                    That was my initial suggestion, but they wanted something algebraic and not computed. Go figure.


                    "Dissent is the highest form of patriotism." - Thomas Jefferson Web - Blog - RSS - Math - LinkedIn - BM

                    E Offline
                    E Offline
                    El Corazon
                    wrote on last edited by
                    #17

                    Bassam Abdul-Baki wrote:

                    but they wanted something algebraic and not computed.

                    you compute an algebraic weight to be attached to any given function based on its performance time. :)

                    _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                    B 1 Reply Last reply
                    0
                    • R Rama Krishna Vavilala

                      Can you give an example or two?

                      Co-Author ASP.NET AJAX in Action

                      B Offline
                      B Offline
                      Bassam Abdul Baki
                      wrote on last edited by
                      #18

                      Nope, it's for a proposal. However, I'm talking about any mathematical equation: (a + b) * sin ( π α ) / sqrt(c) ...


                      "There are II kinds of people in the world, those who understand binary and those who understand Roman numerals." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                      E 1 Reply Last reply
                      0
                      • E El Corazon

                        Bassam Abdul-Baki wrote:

                        but they wanted something algebraic and not computed.

                        you compute an algebraic weight to be attached to any given function based on its performance time. :)

                        _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                        B Offline
                        B Offline
                        Bassam Abdul Baki
                        wrote on last edited by
                        #19

                        True, but they wanted something generic. And like I told others, this was added at the last minute of a proposal and they need it yesterday as usual.


                        "It is the mark of an educated mind to be able to entertain a thought without accepting it." - Aristotle Web - Blog - RSS - Math - LinkedIn - BM

                        J M D 3 Replies Last reply
                        0
                        • B Bassam Abdul Baki

                          Is there a known method for comparing different algorithms? What we're looking for is a way to assign weights to different operands (+,-,*,/) and functions (sin,cos,tan,cot,sqrt) and see how they compare to each other. Is anyone aware of such a method? Thanks


                          "Religion is assurance in numbers." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                          S Offline
                          S Offline
                          Shog9 0
                          wrote on last edited by
                          #20

                          If all you want is a quick "cocktail napkin" comparison, then just count operations by hand, using some large, consistent weight (say, 100) for the trig methods. If the results are close, then you can decide on other factors (clarity, accuracy, ease of optimization, etc.)

                          every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                          B 1 Reply Last reply
                          0
                          • B Bassam Abdul Baki

                            Nope, it's for a proposal. However, I'm talking about any mathematical equation: (a + b) * sin ( π α ) / sqrt(c) ...


                            "There are II kinds of people in the world, those who understand binary and those who understand Roman numerals." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                            E Offline
                            E Offline
                            El Corazon
                            wrote on last edited by
                            #21

                            time each function individually, assign the fastest operation as "1", assign a number to each other operation based on the timing difference between the shortest operation and it. :) + might be 1 - might be 1 * might be 2.5 / might be 5 sin() might be 10 cos() might be 10 sqrt() might be 20 base each number based on calculated differences, you still have a relative complexity based on CPU time. :) of course ignoring cache flushes, but that is a bit more difficult to catch. :)

                            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                            B 1 Reply Last reply
                            0
                            • B Bassam Abdul Baki

                              Is there a known method for comparing different algorithms? What we're looking for is a way to assign weights to different operands (+,-,*,/) and functions (sin,cos,tan,cot,sqrt) and see how they compare to each other. Is anyone aware of such a method? Thanks


                              "Religion is assurance in numbers." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #22

                              I haven't read through all the responses you got, but there was a fellow a week ago or so here that posted some results of a genetic algorithm being used to create numeric algorithms. It was very interesting. Marc

                              Thyme In The Country
                              Interacx
                              My Blog

                              B 1 Reply Last reply
                              0
                              • S Shog9 0

                                If all you want is a quick "cocktail napkin" comparison, then just count operations by hand, using some large, consistent weight (say, 100) for the trig methods. If the results are close, then you can decide on other factors (clarity, accuracy, ease of optimization, etc.)

                                every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                                B Offline
                                B Offline
                                Bassam Abdul Baki
                                wrote on last edited by
                                #23

                                That's what we're doing. However, all operands are based on a multiple of multiplication. The lead architect wishes to use (+/-) = 0.5(*) and (sin/cos)=4(*). I disagreed with that since all trig functions are Taylor series expansions that depending on how many digits, could take much higher to calculate. So we're trying to come up with a happy medium for this and we've settle on three significant digits and/or three Taylor sums whichever is easier.


                                "You can lead a horse to Vista, but it won't get in stall." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                                S 1 Reply Last reply
                                0
                                • M Marc Clifton

                                  I haven't read through all the responses you got, but there was a fellow a week ago or so here that posted some results of a genetic algorithm being used to create numeric algorithms. It was very interesting. Marc

                                  Thyme In The Country
                                  Interacx
                                  My Blog

                                  B Offline
                                  B Offline
                                  Bassam Abdul Baki
                                  wrote on last edited by
                                  #24

                                  Any link?


                                  "Dissent is the highest form of patriotism." - Thomas Jefferson Web - Blog - RSS - Math - LinkedIn - BM

                                  M 2 Replies Last reply
                                  0
                                  • E El Corazon

                                    time each function individually, assign the fastest operation as "1", assign a number to each other operation based on the timing difference between the shortest operation and it. :) + might be 1 - might be 1 * might be 2.5 / might be 5 sin() might be 10 cos() might be 10 sqrt() might be 20 base each number based on calculated differences, you still have a relative complexity based on CPU time. :) of course ignoring cache flushes, but that is a bit more difficult to catch. :)

                                    _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                                    B Offline
                                    B Offline
                                    Bassam Abdul Baki
                                    wrote on last edited by
                                    #25

                                    That's almost what we want, except the multiplication is our normalized number and the plus and minus were roughly half that computation. :)


                                    "There are II kinds of people in the world, those who understand binary and those who understand Roman numerals." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                                    E 1 Reply Last reply
                                    0
                                    • B Bassam Abdul Baki

                                      Any link?


                                      "Dissent is the highest form of patriotism." - Thomas Jefferson Web - Blog - RSS - Math - LinkedIn - BM

                                      M Offline
                                      M Offline
                                      Marc Clifton
                                      wrote on last edited by
                                      #26

                                      Bassam Abdul-Baki wrote:

                                      Any link?

                                      Nope. Sorry. And I have no clue as to whether the CP forum is searchable. But IIRC, it was about 2-3 weeks ago. Marc

                                      Thyme In The Country
                                      Interacx
                                      My Blog

                                      B 1 Reply Last reply
                                      0
                                      • B Bassam Abdul Baki

                                        That's what we're doing. However, all operands are based on a multiple of multiplication. The lead architect wishes to use (+/-) = 0.5(*) and (sin/cos)=4(*). I disagreed with that since all trig functions are Taylor series expansions that depending on how many digits, could take much higher to calculate. So we're trying to come up with a happy medium for this and we've settle on three significant digits and/or three Taylor sums whichever is easier.


                                        "You can lead a horse to Vista, but it won't get in stall." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                                        S Offline
                                        S Offline
                                        Shog9 0
                                        wrote on last edited by
                                        #27

                                        Bassam Abdul-Baki wrote:

                                        However, all operands are based on a multiple of multiplication. The lead architect wishes to use (+/-) = 0.5(*) and (sin/cos)=4(*).

                                        What? So you'd actually halve the score of your algorithm by throwing in an extra add? :~ And yeah, 4x for sine/cosine sounds really, really low. [Edit: I think i read that wrong; you're using multiplication as your baseline, not multiplying weights. Still seems odd... ]


                                        Last modified: 5mins after originally posted -- where's my head at...

                                        every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                                        B 1 Reply Last reply
                                        0
                                        • M Marc Clifton

                                          Bassam Abdul-Baki wrote:

                                          Any link?

                                          Nope. Sorry. And I have no clue as to whether the CP forum is searchable. But IIRC, it was about 2-3 weeks ago. Marc

                                          Thyme In The Country
                                          Interacx
                                          My Blog

                                          B Offline
                                          B Offline
                                          Bassam Abdul Baki
                                          wrote on last edited by
                                          #28

                                          Marc Clifton wrote:

                                          And I have no clue as to whether the CP forum is searchable.

                                          The Lounge is, the SoapBox isn't worth it. :-D


                                          "There are II kinds of people in the world, those who understand binary and those who understand Roman numerals." - Bassam Abdul-Baki Web - Blog - RSS - Math - LinkedIn - BM

                                          M 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups