Posts

Showing posts from 2017

Basic Matrix Operations (easy to use/read)

Image
\( 0_{m \times n} \)  denotes the  \( m \times n \)  zero matrix , with all entries zero. \( I_{n} \)  denotes the \( n \times n \)  identity matrix , with \( I_{ij}= \cases{ 1 & i = j \cr 0 & i $\ne$ j } \) For example;  \( 0_{2 \times 3} = \left\lbrack \matrix{ 0 & 0 & 0 \cr 0 & 0 & 0 } \right\rbrack, \)  \(  I_{2} =  \left\lbrack \matrix{ 1 & 0 \cr 0 & 1 } \right\rbrack \) Transpose of Matrix  \( A = \left\lbrack \matrix{ a & b & c \cr d & e & f } \right\rbrack {⇒}  \)  \({A^T} = \left\lbrack \matrix{ a & d \cr b & e \cr c & f } \right\rbrack \) Summation of Matrices (entrywise) \( \left\lbrack \matrix{ a & b \cr c & d } \right\rbrack + \left\lbrack \matrix{ x & y \cr z & t} \right\rbrack = \left\lbrack \matrix{ a+x & b+y \cr c+z & d+t } \right\rbrack\) Subtraction of Matrices (entrywise) \( \left\lbrack \matrix{ a & b \cr c & d } \right\rbrack - \left\lbrack \matrix{ x

Allocate and free memory VS. allocate first, process only for each time

Image
Once upon a time, I was trying to write some code for some robot hardware's serial communication part. I had a desktop pc, no memory restrictions (8GB RAM, i3 CPU etc.) and that particular program communicated with microcontroller via USB(Fullspeed) or Serial with 115200 baudrate. I had around 20 to 30 methods which used this communication function and because of that I was really curious how its processing time affected my work.. Only one instance of this function is running at the same time. The question is... Which one is more effective to process data faster? 1. Define first, use every time; ... private : struct timespec ctv1 , ctv2 ; double time_diff ; int serial_write_ret ; int ret_val ; ... int MSerial :: genAndSend_setInt32Command () { genSum ( stm_buf_t ); sem_wait ( & serial_mutex ); // someFunctions(); sem_post ( & serial_mutex ); return ret_val ; } 2. Or allocate and deallocate every t

Connecting to Wifi by Command Line with nmcli

Image
Basic usage for lazy people All you have to do is; Get if-name, Add network, Edit password, Connect. 1. Getting if-name Open up terminal and use   ifconfig  command. (Do not use the   $  sign, it means, you are normal user) Or you can use   ip a  . Its output will be similar. $ ifconfig output of   ifconfig  , should be like this; eth0 Link encap:Ethernet HWaddr b8:27:eb:bf:29:a3 inet6 addr: fe80::2ca2:37c8:4331:ac8a/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 ( 0 .0 B ) TX bytes:0 ( 0 .0 B ) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:328 errors:0 dropped:0 overruns:0 frame:0