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. General Programming
  3. C / C++ / MFC
  4. plus arrays

plus arrays

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structuresquestion
3 Posts 3 Posters 0 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.
  • G Offline
    G Offline
    gentleguy
    wrote on last edited by
    #1

    dear friend what problem is following calculation? thanks here gbest is a 3x4 array for (int i =0;i<10;i++) { for (int j = 0;j<3;j++) { for (int k = 0;k<4;k++) v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); x[i][j][k] = x[i][j][k] + v[i][j][k]; } } computer showed me: error C2064: term does not evaluate to a function taking 1 arguments error C2112: '-' : pointer subtraction requires integral or pointer operand

    Li Zhiyuan 5/10/2006

    J F 2 Replies Last reply
    0
    • G gentleguy

      dear friend what problem is following calculation? thanks here gbest is a 3x4 array for (int i =0;i<10;i++) { for (int j = 0;j<3;j++) { for (int k = 0;k<4;k++) v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); x[i][j][k] = x[i][j][k] + v[i][j][k]; } } computer showed me: error C2064: term does not evaluate to a function taking 1 arguments error C2112: '-' : pointer subtraction requires integral or pointer operand

      Li Zhiyuan 5/10/2006

      J Offline
      J Offline
      Joan M
      wrote on last edited by
      #2

      if gbest is an array, shouldn't it have the dimensions at its side? v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); shouldn't it be: v[i][j][k] = w*v[i][j][k] + c1*rand()*(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()*(gbest[i][j][k]-x[i][j][k]); Hope this helps...

      https://www.robotecnik.com freelance robots, PLC and CNC programmer.

      1 Reply Last reply
      0
      • G gentleguy

        dear friend what problem is following calculation? thanks here gbest is a 3x4 array for (int i =0;i<10;i++) { for (int j = 0;j<3;j++) { for (int k = 0;k<4;k++) v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); x[i][j][k] = x[i][j][k] + v[i][j][k]; } } computer showed me: error C2064: term does not evaluate to a function taking 1 arguments error C2112: '-' : pointer subtraction requires integral or pointer operand

        Li Zhiyuan 5/10/2006

        F Offline
        F Offline
        fd0129002
        wrote on last edited by
        #3

        I guess pbestArray is a pointer to the array, so I think pbestArray[i][j][k]-x[i][j][k] should be (*pbestArray)[i][j][k]-x[i][j][k] And , as Joan Murt said, you should add "*" between rand() and ...(something after it). May you good luck

        ============ Einstein Seeing is believing.

        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