In many instances one may need to append a character or a value in a given sequence, usually represented as a vector or array. It is pretty easy to achieve this naively. However, the point is not to consume any more memory. This is one of the simple solutions I can propose in GNU R.
# This function appends a word into vector a in every f element
appendfreq<-function(a,f,word) { i <- as.integer(length(a)/f-1); q<-f; for(j in 1:i) { a<-append(a,word,after=q); q<-q+f+1; } ;return(a); }
Wednesday, 10 March 2010
Tuesday, 12 January 2010
GNU R Garbage Collection
On GNU R if you delete your objects by
rm(list=ls())
This action won't free any memory associated with those objects. For this reason, R provides a utility for garbage collection, simply apply
gc()
This will free not used allocations. If you like to apply this whenever R allocates memory, apply this:
gctorture(on = TRUE)
Consult with R Internals manual for further details.
rm(list=ls())
This action won't free any memory associated with those objects. For this reason, R provides a utility for garbage collection, simply apply
gc()
This will free not used allocations. If you like to apply this whenever R allocates memory, apply this:
gctorture(on = TRUE)
Consult with R Internals manual for further details.
Thursday, 10 December 2009
Groebner Bases and Cryptography
You may have already heard the brilliant technique called Groebner bases to solve multivariate system of equations. But unfortunately it is pointed out that it isn't possible to use this in cryptography: [Why you cannot even hope to use Groebner Bases in Public Key Cryptography?].
Wednesday, 15 October 2008
Deleting extraneous files from destination: rsync
There were some reported non-functioning --delete flag when using rsync in syncronizing two filesystems/locations. This may occur due to failures or errors during rsync tries to sync zero size files. One simple work around for this is using --ignore-errors flag. Some examples for taking backup of user directory:
rsync -vaz -e ssh --delete --ignore-errors user@host:/home/user/ local_dir/
rsync -vaz --delete --ignore-errors /home/user/ /media/disk/backup_dir/
rsync -vaz -e ssh --delete --ignore-errors user@host:/home/user/ local_dir/
rsync -vaz --delete --ignore-errors /home/user/ /media/disk/backup_dir/
Subscribe to:
Posts (Atom)
