c++ - Return type of abs is complex? -


क्या std :: abs एक जटिल मान वापस करता है? यही है, एक वास्तविक मूल्य शून्य काल्पनिक भाग के साथ एक जटिल संख्या के रूप में दर्शाया गया है। मुझे यह त्रुटि मिलती है

g ++ -march = native "utilities.cpp" -fpic -g -Wall -c -std = c ++ 11 -i "/ घर / टॉर्बोजर / तैनात" - O "__wand_targets_dbg / utilities.o"

फ़ाइल में /usr/include/c++/4.8/algorithm:62:02 से शामिल है, / home / torbjorr / तैनात / जड़ी बूटी / मेमोरी / मेमोरीएच: 14, /home/torbjorr/deployed/vector/matrixstorage.h.10 से, frame_in.h: 9 से, utilities.cpp से: 6: /usr/include/c++/4.8 /bits/stl_algo.h: '_OIter std :: transform (_IIter, _IIter, _OIter, _UnaryOperation) के तत्काल में [_IIter = std :: जटिल & lt; float & gt; *] के साथ; _OIter = फ्लोट *; _ यूनानीऑपरेशन = std :: जटिल & lt; float & gt; (*) (Const std :: complex & lt; std :: complex & lt; float & gt; & gt; & amp;)] ': utilities.cpp: 89: 34: यहां से आवश्यक / usr/include/c++/4.8/bits/stl_algo.h : 4926: 12: त्रुटि: 'std :: जटिल & lt; float & gt; असाइनमेंट में 'फ्लोट' करने के लिए * __ परिणाम = __unary_op (* __ पहले);

जब ऐसा कहा जाता है:

  std :: transform ( स्पेक्ट्रम.बीजीन (), स्पेक्ट्रम.एंड (), टेम्पक.बीजिन (), स्टडी :: एब एंड लेफ्टिनेंट; स्टैडी :: कॉम्प्लेक्स; & lt; float & gt; & gt;);   

cppreference.com से:

  टेम्पलेट & lt; वर्ग टी & gt; टी पेट (कॉस्ट कॉम्प्लेक्स & lt; T & gt; & amp; z);   

तो इस मामले में, मैं एक फ्लोट वापस की उम्मीद है।

  std :: transform (spectrum.begin (), स्पेक्ट्रम.एंड (), टेम्प.बेजिन (), std :: abs & lt; std :: जटिल & lt; float & gt; & gt;);   

यहां ध्यान दें कि आप std :: abs & lt; std :: complex & lt; float & gt; & gt; उपयोग करने का प्रयास कर रहे हैं। उस मामले में, टेम्पलेट तर्क T है std :: जटिल & lt; float & gt; । यदि आप T को std :: abs के हस्ताक्षर में बदलते हैं, तो आपको यह मिलता है:

  std :: जटिल & lt; float & gt; पेट (const std :: जटिल & lt; std :: जटिल & lt; फ्लोट & gt; & gt; & amp; z;);   

मेरा मानना ​​है कि जिस कार्य का आप उपयोग करना चाहते थे वह std :: abs & lt; float & gt; था, जिसके परिणामस्वरूप इस प्रकार हस्ताक्षर होंगे:

  फ्लोट एब्स (कॉन्स्ट स्टैट :: कॉम्प्लेक्स & lt; float & gt; & amp; z);    

Comments

Popular posts from this blog

Delphi: missing interface declarations for UI Automation methods -

php - how to change mysql_result($res, 0, "url"); to mysqli -

android - How to attach an image from an app to gmail -