
I used VC++ 2008...there is not as much fussy issue, as VC++ 2012 is producing(useless hurdles)....program itself has complex logic...
Issue is closed..I changed environmnt vc++ 2008..






This has nothing to do with C/C++ programming.





Not really a question for a programming site but as it's in my area. You configure the LM317T as a current source you can neglect the voltage totally. There is a formula for trickle charge rate of NiMh an online calculator is here Rechargeable battery charging time and mA current calculator  Convert to units and culinary measures.[^]
For a 2000maH stack maximum trickle charge rate is 66mA which is well within range of your solar panels. You can't charge any faster using a simple LM317T circuit otherwise you will damage the batteries.
Finally the circuit is shown here (second one with the solar panels)
NiCad Battery Charger with LM317  Jose Pino's Projects and Tidbits.[^]
The 22 Ohms on the circuit will give you 56mA of trickle charge .. if you want exact max 66mA you need 19 Ohm 1/2 Watt resistor.
The diode protect (1N4001) protects the solar panels when they aren't in sunlight
You want a more advanced charger go to a proper electronics hobby site and not here
In vino veritas





It is site driving spam.
The text has been copied from a 2014 StackExchange post and extended with a link to the distributor.





Haha I get it now .. will ignore in future.
In vino veritas





Messagepassing on the binary erasure channel
Code word =[1 0 0 1 0 1]
Y= [1 0 0 x x 1]
Procedure DECODE(Y)
I= 0
For i= 1 :n do
Mi=yi
end for
repeat
for j= 1 :m do
for all i ∈Bj do
if all messages into check j other than M i are known then
end if
end for
end for
for i= 1 :n do
if Mi= ‘unknown’then
Mi=Ej,i
end if
end if
end for
if all Mi known or I =Imax then
Finished
else
I=I+ 1
end if
until Finished
end procedure






I am working LDPC encoding and decoding for mini project work. With my effort i have completed LDPC encoding but struggling with LDPC decoding.
Messagepassing on the binary erasure channel
Code word =[1 0 0 1 0 1]
Y= [1 0 0 x x 1]





Can anyone help me in writing C languageLDPC Decoding:Looking for logic using algorithm.algopng for decoding procedure. Please give me logic.






I have already know that in Wikipedia, Lowdensity paritycheck code is given but not the logic. I have gone through all the theory parts. Thanks for your logic.





If you have gone thru the problem them you should have already realized, you can't decode anything until you first sort out the type of encoding. LDPC isn't one thing it is a verbose description of any number of schemes it is an NPcomplete code problem. So you may have read the wikipedia article but you don't understand it.
Effectively you just asked us to help us build a vehicle and we don't know if it's a car, boat, truck, train, hovercraft or plane.
Look all I can do is point you at
GitHub  jontio/LDPC4Qt: Forward Error Correction using LDPC codes with Qt C++[^]
As it says the code on there is too slow and totally useless for any sort of real world use it will just get you to understand LDPC codes.
In vino veritas





Hi,
I have completed my LDPC encoding part and got output. Now i switched over to LDPC decoding part. I know procedure of LDPC decoding very well, but in Coding part i am feel little bit difficult.





If you know it very well, you should be able to write down the steps. Once you have the steps written down, you should then be able to further break them down into logical programming structures. You solve this just like any other programming problem by breaking it down and down until you have a clear understanding of what code needs to be written.
This space for rent





So what form of the decoder are you trying to write?
Some I am familiar with, others I am not. I don't claim to know every type of LDPC decoder on the planet.
If you haven't chosen one then perhaps read an analysis .. this was done for the DVBS2 specification
[Investigation of LDPC code in DVBS2]
In vino veritas
modified 21Jun17 9:29am.





I know concepts of message_passing decoding or bit_flipping decoding techniques. So i am trying C codes for message_passing decoding or bit_flipping decoding.





Actually i am not getting about the type of decoder concerned with partially parallel or fully serial bcoz I have to implement the LDPC decoder with the help of belief propagation algorithm.In that process i have been provided with a H matrix,code word like [0 0 1 0 1 1] for a 4*6 matrix.The received word is r=[1 0 1 0 1 1] with a cross over probability of p=0.2.
Now the steps which i have to follow for computation is as follows:
1.in the first step using logp/1p i have to find out the received word and it comes like
r=[1.3863,1.3863,1.3863,1.3863,1.3863,1.3863]
2.Since it is a 4*6 matrix
M11=r1=1.3863 and M31=r1=1.3863
for i=2,M12=r2=1.3863 and M22=r2=1.3863
.
.
.
.
for i=6 M36=r6=1.3863 and M46=r6=1.3863
3.Extrensic information.It is calculated by using formula
E11=log(1+tanh(M12/2)tanh(M14/2)/1tanh(M12/2)tanh(M14/2))
Like that i have to calculate for eacha nd every node and finally a E matrix has been formed
4.calculation of LLR
L1=r1+E11+E31=some value
.
.
.
.
L6=some value
finally on the basis of BPSK scheme
Z=[0 0 1 0 1 1]
5.To check if Z is a valid codeword
S=Z.H transpose
if it comes like [0 0 0 0] then my code word is correct otherwise have to go for next iteration.
Please tell me how should i proceed.Its a total mathematical calculation.I am stuck with the point of taking matrix as a input.If i take it as an array also then how should i calculate that tanh calculation.





You have totally lost me ... you are giving me the formulas
tanh is a standard C/C++ function (C library function  tanh)
You have the matrix coefficents and like you said the E matrix first coefficent is
E11=log(1+tanh(M12/2)tanh(M14/2)/1tanh(M12/2)tanh(M14/2))
So plug the numbers in and calculate your E matrix coefficents
You do all your other calculations and then transpose the matrix .. you know
C Program to Find Transpose of a Matrix]
You need to explain this statement => "how should i calculate that tanh calculation". I simply don't get it tanh is a trig function like sine/cosine/tan and it just needs "#include <math.h>" and you have it on any C/C++ compiler that meets the oldest C89 standard.
You gave me coefficent values above so I know you know what M12,M14 are and you know what a 2 is.
So I query why you ask me how do you do the tanh calculation, why didn't you ask me how you do the log calculation? What is the difference between those that is causing your problems?
In vino veritas
modified 22Jun17 16:52pm.





Hi
I had a block of code in my project that was repetitive. So I decided to make it a MACRO
In my block of code I had a For loop, which needed int i; as a variable
in order to make it unique I tried to use __COUNTERS__ macro
e.g. i##_COUNTERS__. I was never able to get the code to compile
I came upon a alternate solution wrapping the code around curly braces
As I remember anything declared within curly braces is unique to that block
of code. Am I correct in this
thanks





If I understand you, then yes  a variable declared inside {}'s is local to that block of code (or "scope").
So, you could do something like:
#define DOALOOP(x) { for (int i = 0; i < X; i++) { DoSomething (i); } }
and you would not mess up any other "i"s there. This is called shadowing, and can be powerful... Or causes confusion if you do it by accident!
I am one of "those foreigners coming over here and stealing our jobs". Yay me!





Avoid complex macros. Search the web for something like "c++ macro vs function" or "c++ avoid macros" to know about the problems.
When using C++ and a macro should be type independant, use templates instead. Otherwise just use (inline) functions. These are the common methods to implement repetitive code.





+10 to Jochen's answer
Complex Macros are evil and usually cause problems down the track, avoid them.
If you are really sensitive inline the code but realistically all modern compilers like GCC and VC++ will inline anything you spot anyhow. They also have setting to control the behaviour.
On GCC O2 will inline blocks that a heuristic analysis code determines is worth it and results in smaller code. With O3 will inline blocks that the heuristic analysis code determines is worth it regardless of size.
It also has an attribute to add to a code block __attribute__((always_inline)) which will force an inline whenever used.
In VC++ the setting is under optimization control called "Inline function Expansion", the setting "any suitable" will allow the compiler to inline any code it decides is worth it.
VC++ carries __forceinline as it's attribute to force a block to be inlined.
I will almost guarantee you that your code using the MACRO will be slower than what the compiler works out by you just writing a normal C/C++ function and letting the optimizer do it's thing
It seems to get lost on the net that the modern compilers are a far cry from the old ones. You get better results by trying to help the optimizer rather than fighting it.
In vino veritas





Are you saying VC++ is smart enough to see what is repeatative code, and will inline it
Thanks





Yep it should pick it just dump the code output to check, manually turn on the optimization flags to make sure it's on (the default will be "default" which is real helpful)
If you are on VisualStudio time to learn how to use the analyzer menu items
Anyhow the oldschool way to do it on VS is set a breakpoint where you want to look at. When it breaks press CTRL+ALT+D (brings up disassembly window) now see if it inlined the code in the assembler/C/C++ code mix on your screen!!
General background on VS optimizer: Introducing a new, advanced Visual C++ code optimizer  Visual C++ Team Blog[^]
General background on IPO:Interprocedural optimization  Wikipedia[^]
VisualStudio GL (Whole Program Optimization)[^](Inline a function in a module even when the function is defined in another module)
In vino veritas
modified 19Jun17 11:45am.



