This is a test Divakar suggest I do to see the speed it takes octave 3.8.1 to run this. Results are below along with the code.
1) Using ismember with 2,000,000 is faster but uses more memory
-elapsed time -0.2306sec- or -0.0038mins-
Total is 15000001 elements using 106000008 bytes
2) Using intersect with 2,000,000 is slower but uses less memory.
-elapsed time -0.3057sec- or -0.0051mins-
Total is 11749047 elements using 93992376 bytes
3) Using bskfun with 100,000 produces an error: out of memory or dimensions too large for octave's index type
First test results:
clear all, clc, tic, clf; num_to_test=2000000 %amount of numbers to test a1=(1:1:num_to_test)'; a2=(a1.*num_to_test); array=[a1,a2]; %array where values are stored lookupval=(randperm(num_to_test,num_to_test/2)/4)'; %lookup these random vaules of intergers and floats and get another value lookupval = sort(lookupval); sort_comb_array = [lookupval zeros(size(lookupval))]; [idA1,idB1] = ismember(array(:,1),lookupval); sort_comb_array(idB1(idA1),2) = array(idA1,2); fprintf('\nfinally Done-elapsed time -%4.4fsec- or -%4.4fmins- or -%4.4fhours-\n',toc,toc/60,toc/3600); whos >>>num_to_test = 2000000 >>> finally Done-elapsed time -0.2306sec- or -0.0038mins- or -0.0001hours- >>>Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a1 2000000x1 16000000 double a2 2000000x1 16000000 double array 2000000x2 32000000 double idA1 2000000x1 2000000 logical idB1 2000000x1 16000000 double lookupval 1000000x1 8000000 double num_to_test 1x1 8 double sort_comb_array 1000000x2 16000000 double Total is 15000001 elements using 106000008 bytes ========================================================================
Second test results:
clear all, clc, tic, clf; num_to_test=2000000 %amount of numbers to test a1=(1:1:num_to_test)'; a2=(a1.*num_to_test); array=[a1,a2]; %array where values are stored lookupval=(randperm(num_to_test,num_to_test/2)/4)'; %lookup these random vaules of intergers and floats and get another value lookupval = sort(lookupval); output = zeros(length(lookupval),2); output(:,1) = lookupval; [c a b ] = intersect(array(:,1),lookupval); output(b,2) =array(a,2); fprintf('\nfinally Done-elapsed time -%4.4fsec- or -%4.4fmins- or -%4.4fhours-\n',toc,toc/60,toc/3600); whos >>>num_to_test = 2000000 >>> finally Done-elapsed time -0.3057sec- or -0.0051mins- or -0.0001hours- >>>Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 250005x1 2000040 double a1 2000000x1 16000000 double a2 2000000x1 16000000 double array 2000000x2 32000000 double b 250005x1 2000040 double c 250005x1 2000040 double lookupval 1000000x1 8000000 double num_to_test 1x1 8 double output 1000000x2 16000000 double Total is 11750016 elements using 94000128 bytes =======================================================================