Tuesday, March 25, 2008

STL: find in a list of pointers

Most STL tutorials will not help you solve this problem:
How to search in a list of pointers?
e.g vector<'obj*'>myList;
The find alogrithm on this will match only the pointer address and if you do not share your objects between classes then your find will always fail as it matches only the pointer addresses and not the value to which it points.
To fix this problem, the solutions that can be considered are:
1. store objects instead of pointers in the list. (huge memory overhead!!)
2. use find_if instead of find and write a functor which compares value instead of pointer address
3. Overload find and implement your own comparator in it. This comparator again compares the value instead of pointer address.

Saturday, March 8, 2008

The basics of Technology Mapping in Digital Circuits

1. Generate the truth table of a given boolean expression
2. Represent the expression in terms of minterms
3. Convert each component into one of the cells of technology map.

Example 1:
a 8x1 multiplexer using a 2x1 mux:
8x1 --> a'b'c'I0 + a'b'cI1 +a'bc'I2 + a'bcI3 + ab'c'I4 + ab'cI5 + abc'I6 + abcI7
==> a'(b'c'I0 + b'cI1 + bc'I2 + bcI3) + a(b'c'I4 + b'cI5 + bc'I6 + bcI7)
==> a'(b'(c'I0 + cI1) + b(c'I2 + cI3)) + a(b'(c'I4 + cI5) + b(c'I6 + cI7))
==> a'(b'M1 + bM2) + a(b'M3 + bM4)
==> a'M5 + aM6
==> M7

Example 2:
AND gate using a 2x1 mux:
AB --> AB + A'0
So the mux will have A as the select line and B on select 1 and tie 0 on select 0

Example 3:
OR gate using a 2x1 mux:
A + B ==> 1(A + B)
==> (A + A')(A + B)
==> AA + AB + A'A + A'B
==> A + AB + A'B
==> A(1 + B) + A'B
==> A1 + A'B
So the mux will have A as the select line and tie 1 on select 1 and B on select 0

Wednesday, March 5, 2008

the awesome GoogleLookUp function

Got this from a ReadWriteWeb:
Try the following on a google spreadsheet
1. Create a Google Spreadsheet
2. Tape "bmw" in A2, "mercedes" in A3 and "nissan" in A4
3. Select A2:A4 and, while holdind the Ctrl key, expand your selection until A50.
4. Say "wow"
5. Tape "employees" from B2 to B50.
6. Enter "=googlelookup(A2; B2)" in C2 and expand the formula until C50
7. "wow", again
8. Take a look at other Google functions in the "Google" tab of this page: http://documents.google.com/support/spreadsheets/bin/answer.py?answer=82712&ctx=
10. "wow", again and again