12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- function initWorkspaceLibSVM
- % function initWorkspaceLibSVM
- %
- % BRIEF
- % Add local subfolders and 3rd party libraries to Matlabs work space.
- %
- % Exemplary call from external position:
- % LIBLINEARWRAPDIR = '/place/to/this/repository/';
- % currentDir = pwd;
- % cd ( LIBLINEARWRAPDIR );
- % initWorkspaceLibSVM;
- % cd ( currentDir );
- %
- %
- % Author: Alexander Freytag
- %% setup paths in user-specific manner
- % currently we do not have any dependencies, but if we would have some,
- % we would add them here
-
- %% add paths which come with this repository
-
- if strcmp( getenv('USER'), 'freytag')
- LIBSMVDIR = '/home/freytag/code/3rdParty/libsvm/matlab/';
- elseif strcmp( getenv('USER'), 'kaeding')
- LIBSMVDIR = '/home/kaeding/lib/libsvm-3.20/matlab/';
- else
- fprintf('Unknown user %s and unknown default settings', getenv('USER') );
- end
-
- % add main path
- b_recursive = false;
- b_overwrite = true;
- s_pathMain = fullfile(pwd);
- addPathSafely ( s_pathMain, b_recursive, b_overwrite )
- clear ( 's_pathMain' );
-
- % for addFieldWithDefault.m
- b_recursive = true;
- b_overwrite = true;
- s_pathMisc = fullfile(pwd, 'misc');
- addPathSafely ( s_pathMisc, b_recursive, b_overwrite )
- clear ( 's_pathMisc' );
-
- %% 3rd party, untouched
-
- if ( isempty(LIBSMVDIR) )
- fprintf('InitPatchDiscovery-WARNING - no LIBSMVDIR dir found on your machine. Code is available at https://github.com/cjlin1/libsvm/ \n');
- else
- b_recursive = true;
- b_overwrite = true;
- addPathSafely ( LIBSMVDIR, b_recursive, b_overwrite );
- end
-
- %% clean up
-
- clear( 'LIBSMVDIR' );
- end
- function addPathSafely ( s_path, b_recursive, b_overwrite )
- if ( ~isempty(strfind(path, [s_path , pathsep])) )
- if ( b_overwrite )
- if ( b_recursive )
- rmpath( genpath( s_path ) );
- else
- rmpath( s_path );
- end
- else
- fprintf('initWSLibSVM - %s already in your path but overwriting de-activated.\n', s_path);
- return;
- end
- end
-
- if ( b_recursive )
- addpath( genpath( s_path ) );
- else
- addpath( s_path );
- end
- end
|