Search Results

Search found 3861 results on 155 pages for 'assignment operator'.

Page 17/155 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Trying to reduce the speed overhead of an almost-but-not-quite-int number class

    - by Fumiyo Eda
    I have implemented a C++ class which behaves very similarly to the standard int type. The difference is that it has an additional concept of "epsilon" which represents some tiny value that is much less than 1, but greater than 0. One way to think of it is as a very wide fixed point number with 32 MSBs (the integer parts), 32 LSBs (the epsilon parts) and a huge sea of zeros in between. The following class works, but introduces a ~2x speed penalty in the overall program. (The program includes code that has nothing to do with this class, so the actual speed penalty of this class is probably much greater than 2x.) I can't paste the code that is using this class, but I can say the following: +, -, +=, <, > and >= are the only heavily used operators. Use of setEpsilon() and getInt() is extremely rare. * is also rare, and does not even need to consider the epsilon values at all. Here is the class: #include <limits> struct int32Uepsilon { typedef int32Uepsilon Self; int32Uepsilon () { _value = 0; _eps = 0; } int32Uepsilon (const int &i) { _value = i; _eps = 0; } void setEpsilon() { _eps = 1; } Self operator+(const Self &rhs) const { Self result = *this; result._value += rhs._value; result._eps += rhs._eps; return result; } Self operator-(const Self &rhs) const { Self result = *this; result._value -= rhs._value; result._eps -= rhs._eps; return result; } Self operator-( ) const { Self result = *this; result._value = -result._value; result._eps = -result._eps; return result; } Self operator*(const Self &rhs) const { return this->getInt() * rhs.getInt(); } // XXX: discards epsilon bool operator<(const Self &rhs) const { return (_value < rhs._value) || (_value == rhs._value && _eps < rhs._eps); } bool operator>(const Self &rhs) const { return (_value > rhs._value) || (_value == rhs._value && _eps > rhs._eps); } bool operator>=(const Self &rhs) const { return (_value >= rhs._value) || (_value == rhs._value && _eps >= rhs._eps); } Self &operator+=(const Self &rhs) { this->_value += rhs._value; this->_eps += rhs._eps; return *this; } Self &operator-=(const Self &rhs) { this->_value -= rhs._value; this->_eps -= rhs._eps; return *this; } int getInt() const { return(_value); } private: int _value; int _eps; }; namespace std { template<> struct numeric_limits<int32Uepsilon> { static const bool is_signed = true; static int max() { return 2147483647; } } }; The code above works, but it is quite slow. Does anyone have any ideas on how to improve performance? There are a few hints/details I can give that might be helpful: 32 bits are definitely insufficient to hold both _value and _eps. In practice, up to 24 ~ 28 bits of _value are used and up to 20 bits of _eps are used. I could not measure a significant performance difference between using int32_t and int64_t, so memory overhead itself is probably not the problem here. Saturating addition/subtraction on _eps would be cool, but isn't really necessary. Note that the signs of _value and _eps are not necessarily the same! This broke my first attempt at speeding this class up. Inline assembly is no problem, so long as it works with GCC on a Core i7 system running Linux!

    Read the article

  • Trouble assigning a tr1::shared_ptr

    - by Max
    I've got a class that has a tr1::shared_ptr as a member, like so: class Foo { std::tr1::shared_ptr<TCODBsp> bsp; void Bar(); } In member function Bar, I try to assign it like this: bsp = newTCODBsp(x,y,w,h); g++ then gives me this error no match for ‘operator=’ in ‘((yarl::mapGen::MapGenerator*)this)->yarl::mapGen::MapGenerator::bsp = (operator new(40u), (<statement>, ((TCODBsp*)<anonymous>)))’ /usr/include/c++/4.4/tr1/shared_ptr.h:834: note: candidates are: std::tr1::shared_ptr<TCODBsp>& std::tr1::shared_ptr<TCODBsp>::operator=(const std::tr1::shared_ptr<TCODBsp>&) in my code, Foo is actually yarl::mapGen::MapGenerator. What am I doing wrong?

    Read the article

  • Perl ||= operator for PHP and Javascript

    - by zaf
    Just been re-introduced to the Perl '||=' operator from the classic Orcish Maneuver example: keys my %or_cache = @in; @out = sort { ($or_cache{$a} ||= KEY($a)) cmp ($or_cache{$b} ||= KEY($b)) } @in; Is this operator available in PHP and Javascript? And if not, do these two languages allow user defined operators?

    Read the article

  • undefined C/C++ symbol as operator

    - by uray
    I notice that the character/symbol '`' and '@' is not used as an operator in C/C++, does anyone know the reason or historically why its so? if its really not used, is it safe to define those symbols as another operator/statement using #define?

    Read the article

  • Javascript IN operator compatibility

    - by jAndy
    Hi Folks, Can someone tell me since which ECMA version the IN operator is available and which browsers (versions) support it ? Explanation: The IN-operator can be used like the following: var myObject = { Firstname: 'Foo', Lastname: 'Bar' }; if('Lastname' in myObject){ // Lastname is an attribute of myObject }

    Read the article

  • c++ global operator not playing well with template class

    - by John
    ok, i found some similar posts on stackoverflow, but I couldn't find any that pertained to my exact situation and I was confused with some of the answers given. Ok, so here is my problem: I have a template matrix class as follows: template <typename T, size_t ROWS, size_t COLS> class Matrix { public: template<typename, size_t, size_t> friend class Matrix; Matrix( T init = T() ) : _matrix(ROWS, vector<T>(COLS, init)) { /*for( int i = 0; i < ROWS; i++ ) { _matrix[i] = new vector<T>( COLS, init ); }*/ } Matrix<T, ROWS, COLS> & operator+=( const T & value ) { for( vector<T>::size_type i = 0; i < this->_matrix.size(); i++ ) { for( vector<T>::size_type j = 0; j < this->_matrix[i].size(); j++ ) { this->_matrix[i][j] += value; } } return *this; } private: vector< vector<T> > _matrix; }; and I have the following global function template: template<typename T, size_t ROWS, size_t COLS> Matrix<T, ROWS, COLS> operator+( const Matrix<T, ROWS, COLS> & lhs, const Matrix<T, ROWS, COLS> & rhs ) { Matrix<T, ROWS, COLS> returnValue = lhs; return returnValue += lhs; } To me, this seems to be right. However, when I try to compile the code, I get the following error (thrown from the operator+ function): binary '+=' : no operator found which takes a right-hand operand of type 'const matrix::Matrix<T,ROWS,COLS>' (or there is no acceptable conversion) I can't figure out what to make of this. Any help if greatly appreciated!

    Read the article

  • Why isn't the boost::shared_ptr -> operator inlined?

    - by Alan
    Since boost::shared_ptr could be called very frequently and simply returns a pointer, isn't the -> operator a good candidate for being inlined? T * operator-> () const // never throws { BOOST_ASSERT(px != 0); return px; } Would a good compiler automatically inline this anyway? Should I lose any sleep over this? :-)

    Read the article

  • What does the C# operator => mean?

    - by Mr. Mark
    Answers to a recent post (Any chances to imitate times() Ruby method in C#?) use the = operator in the usage examples. What does this operator do? I can't locate it in my C# book, and it is hard to search for symbols like this online. (I couldn't find it.)

    Read the article

  • Is return an operator or a function?

    - by eSKay
    This is too basic I think, but how do both of these work? return true; // 1 and return (true); // 2 Similar: sizeof, exit My guess: If return was a function, 1 would be erroneous. So, return should be a unary operator that can also take in brackets... pretty much like unary minus: -5 and -(5), both are okay. Is that what it is - a unary operator?

    Read the article

  • PHP: Object Oriented Programming -> Operator

    - by oman9589
    So I've been reading through the book PHP Solutions, Dynamic Web Design Made Easy by David Powers. I read through the short section on Object Oriented PHP, and I am having a hard time grasping the idea of the - operator. Can anyone try to give me a solid explanation on the - operator in OOP PHP? Example: $westcost = new DateTimeZone('America/Los_Angeles'); $now->setTimezone($westcoast); Also,a more general example: $someObject->propertyName Thanks

    Read the article

  • binary operator "<"

    - by md004
    Consider this expression as a "selection" control structure on integer "x": 0 < x < 10, with the intention that the structure returns TRUE if "x" is in the range 1..9. Explain why a compiler should not accept this expression. (In particular, what are the issues regarding the binary operator "<"? Explain how a prefix operator could be introduced so the expression can be successfully processed.

    Read the article

  • Assignment to LAN queues (qWAN1 & qWAN2) from dual-WAN in pfSense

    - by Kurian
    I need help creating floating rules in pfSense for the following: I have two upper limited download queues qWAN1 and qWAN2 on my LAN interface. Each has its own qACK1, qDefault1 etc. How do I assign all unclassified traffic from WAN1 to LAN->qWAN1->qDefault1 and from WAN2 to LAN->qWAN2->qDefault2. qLink is the one and only default queue on LAN so that I get wire speed to the pfSense host from the LAN.

    Read the article

  • IPv4 private address assignment

    - by helloworld922
    I'm working on a private network which uses static IPv4 addresses as well as DHCP addressing for the physical LAN network. At a previous company I worked at they would assign static addresses in the 10.*.*.* space and all DHCP/LAN addresses were assigned in the 192.168.*.* space. Both of these address spaces are defined in the IPv4 private address space and there were never any internal conflicts. From personal experience at home, school, at work, and pretty much any other machine I've dealt with extensively (Windows and a few Linux distros), the DHCP server would always by default choose an address from the 192.168.*.* address space. Now my question is can I rely on this behavior? Do DHCP servers always by default assign from the 192.168.*.* pool (or any pool other than the 10.*.*.* pool), leaving the 10.*.*.* pool free for private static addressing? If not, under what conditions might a DHCP server choose an address in the 10.*.*.* address space?

    Read the article

  • EMC VNX iSCSI setup - unsure about SP/port assignment

    - by pauska
    We have a new VNX5300 waiting to get configured, and I need to plan out the network infrastructure before the EMC tech arrives. It has 4x1gbit iSCSI per SP (8 ports in total), and I'd like to get the most out of the performance until we jump over to 10gig iSCSI. From what I can read from the docs - the recommendation is to use only two ports per SP, with 1 active and 1 passive. Why is this? It seems kind of pointless to have quad-port i/o-modules and then recommend to not use more than two of them? Also - I'm a bit unsure about the zoning. The best practices guide state that you should separate each port on each SP from each other on different logical networks. Does this mean that I have to create 4 logical networks to be able to use all 8 ports? It also gives the following example: Does this mean that A0 and B0 should sit on the same physical switch aswell? Won't this make all traffic go on one switch (if both A1 and B1 are passive)? Edit: Another brainpuzzle I don't get it - each host (as in server) should not have more iSCSI bandwidth available than the storage processor. What on earth does this matter? If serverA have 1gbit and serverB have 100mbit, then the resulting bandwith between them is 100mbit. How can this result in some kind of oversubscription? Edit4: Wait, what. Active and passive ports? The VNX runs in a ALUA configuration with asymmetrical active/active.. there shouldn't be any passive ports, only preferred ones..

    Read the article

  • University Assignment: Datacenter/Networking Infrastructure for Hosting Company [closed]

    - by TCB13
    My university assigned me to theorizing a data center for an Web Hosting company. The company should provide the following services: Shared WebHosting; Dedicated Servers; VPS (Virtual Private Server); The bandwith (as resquested) is limited to 10 Gbps. Is there any good book / other info I can read (max 100 pages) about how to design a good data center for hosting, what are the best practices and what should be done from a (logical) network perspective, what security policies should be implemented and how the data center should be built (physically)? Thank you ;)

    Read the article

  • Ubuntu 10.04 Windows2003 adding a route for GPO assignment

    - by David Carvalho
    I want the PC's that receive IP from my Ubuntu DHCP3-server to be able to retrieve the GPOs that are on my windows 2003 server. I'm using virtualbox and 3 virtual machines: 1 windows 2003 server 192.168.0.2 with 1 NIC (internal network). 1 ubuntu server 10.04 lts 192.168.0.1 with 1 NIC (internal network) and 3 aliases 192.168.21.0, 192.168.22.0, 192.168.100.0 1 Windows XP machine with 3 NIC's (internal network).

    Read the article

  • Cannot acess the new cloned server even after new IP address assignment

    - by tough
    I was able to clone a Ubuntu 10.04 server residing in Cloud. It appeared that I was not getting some IP for the new VM so I followed some of these: # cd /etc/udev/rules.d # cp 70-persistent-net.rules /root/ # rm 70-persistent-net.rules # reboot I didn't follow the later commands as I was unable to see two eth MACs as available in the referenced site. After this I am able to see some the IP for it, and is different form the original IP, I have added new IP to DNS server. Now when I try to access it with its assigned(new) domain it is directed to the old server. I can see both the VMs running with different IP. Where I might have gone wrong, I am new to this admin thing.

    Read the article

  • Variable Assignment for arguments with a for loop

    - by RainbowDashDC
    Alright, so, I've searched quite a bit on how to do this but I've given up as I simply couldn't find anything. So, I have a code (below); it's main purpose is to get 9 arguments and assign them as a variable-- ignore the echo's and pipping. My question is: How can I simplfy this with a for loop or such so it doesn't take as much code, and if possible, have more than 9 arguments aswell set pkg1=%1 set pkg2=%2 set pkg3=%3 set pkg4=%4 set pkg5=%5 set pkg6=%6 set pkg7=%7 set pkg8=%8 set pkg9=%9 IF DEFINED pkg1 (echo %1.ini 1> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg2 (echo %2.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg3 (echo %3.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg4 (echo %4.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg5 (echo %5.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg6 (echo %6.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg7 (echo %7.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg8 (echo %8.ini 1>> %WINGET_TEMP%\args.rdc 2>nul) IF DEFINED pkg9 (echo %9.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)

    Read the article

  • Pull/push student assignment files from computer lab computers (Windows 7)

    - by mkstreet
    I have a computer lab with about 35 PC's all running Windows 7. The students do their work and save it on the D-drive in a particular folder such as a folder with the same name as the computer's name (e.g. LABPC001). I'd like a centralized way to pull all these folders in to the teacher's computer in the lab to check the assignments. It would be best if this didn't involve using an external website (e.g. Dropbox). I would also like to be able to distribute (send) files to the students in these same folders. I've seen software applications that do this but they cost about US$1000 which is far beyond our means. Suggestions for free, or almost free, best ways to set this up?

    Read the article

  • IP assignment in small network

    - by nooneon
    What is the best way to assign IPs in your opinion? I've got ~100 PCs, some servers and see three ways to assign IPs: Static IPs for every PC/server Static IP reservation by MAC-address in DHCP Dynamic IPs via DHCP. Of course, you can combine them, i.e. dynamic for PCs, static for servers. But, again, what is the best way? How do you do that?

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >