public ConcatVector newWeightsVector ( boolean presize ) { ConcatVector vector = new ConcatVector ( featureToIndex . size ( ) ) ; if ( presize ) { for ( ObjectCursor < String > s : sparseFeatureIndex . keys ( ) ) { int size = sparseFeatureIndex . get ( s . value ) . size ( ) ; vector . setDenseComponent ( ensureFeature ( s . value ) , new double [ size ] ) ; } } setAlwaysOneFeature ( vector , 1 ) ; return vector ; }
This constructs a fresh vector that is sized correctly to accommodate all the known sparse values for vectors that are possibly sparse .