lvalue required as left operand of assignment

Hello everyone! I am new here and I am looking for someone somewhere who can help me get my lab project going here... I am trying to compile an LTE-Cell-Scanner for use with my software defined radio and I've run into this issue:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[ 5%] Building CXX object src/CMakeFiles/LTE_MISC.dir/capbuf.cpp.o
In file included from /root/LTE-Cell-Scanner/src/capbuf.cpp:29:0:
/root/LTE-Cell-Scanner/include/dsp.h: In function ‘itpp::cvec fshift(const cvec&, double, double)’:
/root/LTE-Cell-Scanner/include/dsp.h:47:25: error: lvalue required as left operand of assignment
coeff.real()=cos(k*t);
^
/root/LTE-Cell-Scanner/include/dsp.h:48:25: error: lvalue required as left operand of assignment
coeff.imag()=sin(k*t);
^
/root/LTE-Cell-Scanner/include/dsp.h: In function ‘void fshift_inplace(itpp::cvec&, double, double)’:
/root/LTE-Cell-Scanner/include/dsp.h:64:25: error: lvalue required as left operand of assignment
coeff.real()=cos(kt);
^
/root/LTE-Cell-Scanner/include/dsp.h:65:25: error: lvalue required as left operand of assignment
coeff.imag()=sin(kt);
^
src/CMakeFiles/LTE_MISC.dir/build.make:62: recipe for target 'src/CMakeFiles/LTE_MISC.dir/capbuf.cpp.o' failed
make[2]: *** [src/CMakeFiles/LTE_MISC.dir/capbuf.cpp.o] Error 1
CMakeFiles/Makefile2:121: recipe for target 'src/CMakeFiles/LTE_MISC.dir/all' failed
make[1]: *** [src/CMakeFiles/LTE_MISC.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2


I tried to fix it myself by doing this:

1
2
3
4
    int e = cos(k*t);
    int f = sin(k*t);
    coeff.real(e);
    coeff.imag(f);


It compiled passed that but ran into yet another lvalue issue and I am guessing my solution isn't quite right either... Some assistance would be very nice... I can provide raw code etc.

This is the second issue I ran into after using the above to get passed the compile issue:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[ 77%] Building CXX object src/CMakeFiles/LTE-Tracker.dir/producer_thread.cpp.o
/root/LTE-Cell-Scanner/src/producer_thread.cpp: In function ‘void producer_thread(sampbuf_sync_t&, capbuf_sync_t&, global_thread_data_t&, tracked_cell_list_t&, double&)’:
/root/LTE-Cell-Scanner/src/producer_thread.cpp:127:62: error: lvalue required as left operand of assignment
         sample_temp.real()=(sampbuf_sync.fifo.front()-127.0)/128.0;
                                                              ^~~~~
/root/LTE-Cell-Scanner/src/producer_thread.cpp:129:62: error: lvalue required as left operand of assignment
         sample_temp.imag()=(sampbuf_sync.fifo.front()-127.0)/128.0;
                                                              ^~~~~
src/CMakeFiles/LTE-Tracker.dir/build.make:86: recipe for target 'src/CMakeFiles/LTE-Tracker.dir/producer_thread.cpp.o' failed
make[2]: *** [src/CMakeFiles/LTE-Tracker.dir/producer_thread.cpp.o] Error 1
CMakeFiles/Makefile2:195: recipe for target 'src/CMakeFiles/LTE-Tracker.dir/all' failed
make[1]: *** [src/CMakeFiles/LTE-Tracker.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2


So I am pretty sure I will need help making sure I am fixing these correctly... Please
int e = cos(k*t);
The cosine function doesn't give many integer values: -1, 0 and 1 to be precise. Use
double e = cos(k*t);
instead. Similarly the sine function.

You might be better using the constructor for a complex variable
1
2
complex<double> coeff;
coeff = complex<double>( cos(k*t), sin(k*t) );


Alternatively, and more directly in this instance:
coeff = polar( 1.0, k*t );

Similar things are happening with your later error, although setting real and imaginary parts to the same quantity seems unlikely.

See http://www.cplusplus.com/reference/complex/






Last edited on
Topic archived. No new replies allowed.