A density-functional study of undoped and doped trans polyacetylene